You can include this code by creating a new custom plugin which help you to stop this when you deactivate the plugin.
wp_schedule_event(time(), 'daily', 'my_dailyClearOut');
function my_clearOldUsers() {
global $wpdb;
$query = $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE datediff(now(), user_registered) > 7");
if ($oldUsers = $wpdb->get_results($query, ARRAY_N)) {
foreach ($oldUsers as $user_id) {
wp_delete_user($user_id[0]);
}
}
}
add_action('my_dailyClearOut', 'my_clearOldUsers');
Related Posts:
- Should all plugins be encapsulated in a Class?
- Consuming an external API in WordPress?
- How can I import a class privately into a plugin?
- Keep one user logged for a year?
- How do I extend one plugin I’m writing with another I’m writing using classes?
- Generate custom output for page/URL in a plugin
- Post source link plugin – small modification
- Add CSS animation as Preloader to WordPress
- How to list the Hooks and order of execution in current loading page? [duplicate]
- Setting up widgets in wordpress with a unique ID for the after_title argument
- Akismet plugin is deleting spam despite preferences
- Modifying Footnote Plugin for Descriptive Title Attributes
- How to expire all wordpress user passwords instantly?
- How to Replace Words with Hypertext Link But Ignore Previously Existed Links?
- force customers to add only single item to card per purchase EDD [closed]
- Edit Yoast SEO breadcrumbs output [closed]
- How would I go about creating a user ranked post popularity page?
- wp_set_auth_cookie causes 403 error in the wooCommerce checkout
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- Redirect to another page using contact form 7? [closed]
- Inserting custom PHP script on homepage
- Add User Role: Pre-saved in User-Meta [SOLVED]
- Loop in elementor custom widget not working
- get_users(); Is an Undefined Function When Used in Cron Job
- I am trying to make a field show and save from quickedit screen
- .php file for woocommerce edit category? [closed]
- Customize Menu | Styling LESS/SCSS code formats
- Why is it important to check for isset and is_array before checking in_array in this example?
- Comment “like” problem – “users who like this” avatar linking to current user profile instead of “liker’s” profile
- Calling a save function from a “submit” button
- same user role or copy the user role to be same as the other role
- How to fix these PHP Warnings with the “Feed JSON” plug-in?
- woocommerce remove coupon link does not work
- implement custom roles in custom plugin
- Post source link plugin – small modification
- Can we hide a certain user in WP?
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- Adding discount functionality to the cart
- How to assign a specific service to a specific provider based on location
- Precheck fields when I add a new post
- Rename a folder via HTML POST request
- Move plugin pages from dashboard to front-end
- working code, not working – Plugin Dev
- Cron job shedules replace?
- Custom shortcode being shown in WPBakery backend rather than the block
- Move plugin upload folder from mywebsite.com/wp-content/uploads/pdfuploads to mywebsite.com/pdfs?
- Woocommerce list variations that are added already to cart in Single Product
- How can I store user preferences in WordPress and retreive them later?
- Flexslider empty slide
- Custom SportsPress list
- How can I save cookies to members
- Confusing problem with displaying message recipient metadata
- Every time I use wp_get_current_user() my plugin breaks
- How to order users alphabetically by name? in plugin UPME
- How to fix vanilla comments extra iframe space
- I want to remove the register/login WordPress top bar from my website
- How to delete remain data in WP database after deleting custom post via admin interface
- What can I do to customize a widget provided with this plugin? from where have I to start?
- WordPress: code structure
- How to give different user access to different people?
- How to make a Template page to show the information of different things Shop and Product page?
- custom user profiles like linktree fully customizable on the front end
- Recommendations for books/resource to get started with wordpress 3 development (plugins/themes) [closed]
- Uncaught Error: Call to undefined function get_user_by() after moving function from theme to plugin
- Getting media library popup in custom plugin admin page
- Sort products without thumbnail in WooCommerce shop page
- Create or Update thousands of woocommerce products via PHP
- cURL error 60: SSL certificate problem: unable to get local issuer certificate
- How to get images from EDD post?
- Can’t get custom posts of taxonomy to show
- How to add pagination to wpbakery grid?
- send_headers don’t work on wordpress multisite
- Can’t create term for product attribute
- Add multiple attributes to product from php
- Organising the plugins folder in wordpress
- Cannot run the code after I activate the plugin
- How to show popup to a group of users?
- jQuery function didn’t work in my plugin
- Displaying admin notice dynamically
- Can I check plugins and themes for PHP 5.6 ahead of global PHP server Update
- bulk change of image setting “link to” to “link to: image url “
- How to add rewrite rules and pagination to retrieve attachments files?
- Displaying Gravity Form data on WordPress page [closed]
- Improving a Stackoverflow “inspired” badge system to display badges in author page
- Mass Import Users without sending new user notification
- WordPress and WebRTC?
- Get a list of galleries from an album in NextGEN Gallery [closed]
- How to install and activate a plugin via an external PHP script
- Current user in plugin returns NULL
- how to include a simple jquery file into a wordpress plugin
- Calling a plugin in theme development
- Will Flutter work with WordPress 3.0?
- Display a text message if the field is not found and not if found
- Unable to activate wordpress importer after installing it
- Reposition Woocommerce Message
- Leveraging WordPress Comments on Custom Plugin Object page
- Copyright messages for a particular set of pages
- Sanitizing, Validating and Escaping in WordPress (Plugin)
- Debugging Technique Question re: functions.php
- Get total number of comment of the posts written by an author