Wordpress Password Expiration - Change value or Create a plugin? - wordpress

One of our Wordpress websites have hundreds of users...when a new user is created, the link is sent to them that expires within a 24h period.
Now, I see that we can change that by changing the a value within the Core of Wordpress: /wp-includes/users.php
Now, would it be better to change the value directly via FTP or create a plugin?

TLDR;
Never edit core files. Go the plugin route instead.
Every time you update WordPress, all core files are replaced by the new ones so editing its code directly is never a good idea: all changes made to it will be lost. Instead, make use of the many action/filter hooks WordPress offers to alter its behavior - this is the safest way to go as upgrades won't overwrite your modifications.
In your case, the password_reset_expiration filter hook is what you're looking for.

Related

What is a good action to use to update the WP database from my plugin?

I need a good trigger to use in my plugin to kick off changes to the website.
I've got a custom plugin that goes on all WordPress sites that I build. I've got it set up to auto-update the plugin.
Occasionally, I need to push out an update across all websites. For instance, there was a plugin that started causing issues across all sites so I wrote code in my function to deactivate it across all sites.
Now I'm writing code to remove some old users that should no longer have access to the site. To deactivate the plugin, I used the action 'plugins_loaded'. Of course the problem there is that it runs EVERY time the plugins are loaded so it runs on EVERY page load. It's pretty fast but still not the right way to do it.
I tried to find some sort of way to kick that one off only when the plugin is updated. Really, I just need these functions to run once ever.
Is there a good action I could use to make sure that happens?

using woocommerce api locally

I'm creating a wordpress plugin that communicates with woocommerce installed on the same wordpress site. I noticed that the rest api requires ssl to use, but it seems like ssl locally is not possible and oauth is a pain in the ass.
Is there a way to develop for woocommerce locally without having ssl that doesn't use oauth?
I would recommend beginning by throwing out the idea of calling back to a local site over any HTTP/S protocol. That is almost never the right decision.
Instead, woocommerce has extended the WordPress hook/filter system into themselves: https://docs.woocommerce.com/document/introduction-to-hooks-actions-and-filters/. This allows you to inject/extend yourself throughout woocommerce without making a cludgy callback system. I don't know what you want/need to do, but I can guarantee the hooks should probably get you all the functionality you will need.
If you truly do need to make API calls back. You basically won't be able to develop locally (without a lot of effort setting up a local server environment). Instead set up a development environment on a separate server.
I assumed this is a mostly php plugin running on the server. If instead this will be serving a lot of javascript to the frontend, then you will have to use the REST API, and you will have to get some development server up with ssl.
Update: based on comment below expounding on purpose. I assume you figured out to add the 'sales goal' information as post meta to the woocommerce product. Here's a quick introduction to post meta if you need it: https://dsgnwrks.pro/how-to/what-is-post-meta-an-intro-to-wordpress-custom-fields/. This would be the best practice for adding information to the products.
For the proportion of sales to the goal. You will first need a function to get the total sales to date on this product. Here is a gist that hooks into woocommerce_single_product_summary and gets the post_meta total_sales on the current product. You should be able to use a similar scheme to get both total_sales and your sales_goal post meta and then just display the ratio in whatever way you choose.
Note: You may need to attach to a different hook. Or you may even need to get the current product a different way (maybe specified by the widget?) to get ahold of the post_meta.

Wordpress : Why Plugin name is unique?

I am new in wordpress. I have read lots of about the plugin creation and thier steps. Can any body explain me why the plugin name is unique? I have read that for avoiding conflict keep plugin name unique. My question is if I have created different or unique shortcode then whats the problem?
In case you publish it, it needs a unique name to display on the WordPress page (or wherever).
How would a regular user know which plugin is the right one if both have the same name? Less computer-savvy users wouldn't be able to check for the plugin code to differentiate them.
Also, the plugin files are named after the plugin name itself. And Wordpress uses this information internally. If two plugins that happen to have the same name were installed under the same Wordpress website, there might be conflicts on Wordpress representation.
A WordPress plugin identified on WordPress.org by its name only. So if plugin name is not unique, even on a local computer for testing, plugin might be overridden automatically by the next update from by a developer with the same app name published in wordpress.org/plugins/.
What happens when you upload manually a none unique name plugin to your WordPress blog? I guess it will be damaged or hacked by anyone who publishes plugin with the same name. That is why not only the name must be unique but you also have to publish it on wordpress.org/plugins/ to prevent anyone change it, or else you have to disable plugin updates.

How to make changes are not visible in userside using wordpress

I want to edit contents of the existing page in wordpress.It is a live site so user side should not be changed
untill i want to publish that after all changes made to that page.Is there any plugin or what
i have to do for this.
Anyone please help me.
It depends what sort of changes. As noted above if you're channing post contents if will be enough not to publish them, but I guess you already now that.
However if you want to change appearance of the site then caching plugin might help. E.g. with w3 total cache you can do any change to template/css/php and so on and only logged in users will see changes (any non logged in user will get cached version of the page until you clean cache or cache expires).
If you have also users which are logging in into your wordpress, then I'm not aware of already made plugin that have such functionality - you probably would have to create development version of your site and test changes there.
For content - agree with previous answers.
But if you are changing the theme and want some changes to be visible only for you (admin) then you can use is_admin() function to print out different content for admin (new one) and different for other users (old one).
http://codex.wordpress.org/Function_Reference/is_admin

Auto blog creation in a WordPress multisite environment

I'm looking for a way to have users register on a multisite setup and have a blog automatically created for them... no, not the way the standard ms registration system handles it. I want to get rid of the second step in the process completely. They register as 'user', and a blog is automatically created at http://my.site.com/user for them.
Followup question... anyone know of a way of automatically pruning the multisite platform? IE, users who don't login for 'x' timeframe (or after a certain time period has elapsed) automatically have their site deleted.
Just make one pure copy of Wordpress files and database layout just after wordpress instalation. When you will have it, after user complete registration just copy files from original directory like "_original_wordpress" to "username_dir", and create new database or just add tables with username_ prefix in them. Also you have to cofigure config.php or whatever there is in wordpress that contains database data.
As for 2nd problem - use CRON. Write script in PHP that lists all users who was last active before month ago, delete tables from database in MySQL and dir "/username/" and it's gone :) And so that it would be executed regulary, just put it in CRON like every day once?
Well thats just one of the way to solve any of your problems but it look very simple.

Resources