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?
- Checking if an attribute exists in a shortcode
- How Is Network Activate Different From Activate (by Implementation)?
- Delete Post With No Traffic?
- Automatically Creating Posts for Popular Forum Topics or Products [closed]
- What’s the recommended process for organising collaborative posting?
- Multi step form, custom plugin
- Can I check plugins and themes for PHP 5.6 ahead of global PHP server Update
- How to transfer all user data between wordpress installations?
- add_query_arg not working
- Translation plugin to translate another plugins
- Notice: Uninitialized string offset: 0 in social sharing mu-plugin
- Shortcode to update user meta
- How to Loop Through all Posts and Count Attachments using Get Media Attachments
- Contact Form 7 – Form name blank [closed]
- how can I query all wordpress users of a blog
- How to redirect to same page after form submission
- How to add a new column with text fields to WooCommerce Cart List?
- Creating an admin meta box to save post as pending
- Custom meta box with jQuery.sortable custom post type list
- Passing value as hidden parameter to next page
- Apply html elements in php statement
- Get product categories and add them to a custom taxonomy
- Auto populate a user custom field from another user custom field
- add_rewrite_rule to load different page, without changing URL in browser
- Plugin or ways to limit number of users logging in the website,
- WP Ajax DB issues
- Multiple image selection custom widget
- Paid Membership Pro displaying a user name in PHP
- Creating Nested custom fields
- Plugin does not create a custom table upon activation
- Hyperlink to execute PHP
- How to get site homepage from plugin?
- admin panel save option with ajax
- update_post_meta not working
- Pulling Advanced Custom Fields from other pages
- Option value not getting updated until page refresh in WordPress
- Fatal error: Uncaught Error: Call to a member function fetch_array() on bool
- Use inline callable for hooks and filters
- Error in using ‘admin_enqueue_scripts’ action through a class