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?
- Best collection of code for your 'functions.php' file [closed]
- OpenID for WordPress 3.x? [duplicate]
- if plugin is active? check if plugin is enabled or not?
- Making plugin unique to not conflict with plugins with the same name
- How to store ACF custom fields data in a custom table
- Trying to disable plugins doens’t work
- Have Plugin Handle Specific URLs
- Set Post Format if find a string in title or post content
- Do widget options need to be escaped widget()?
- Is there any W3C compatible Share & Follow plugin?
- WordPress Shortcode to get URL Parameters $_GET[‘name’] redirects for no reason at all
- How to check if a taxonomy not exists in a plugin
- How passing values to construct function with Actions?
- wordpress add_action() issue in ajax call
- Using ‘mysqli_connect’ ‘crashes’ WordPress client-side
- eaccelerator PHP error
- Looking for a good way to include php code in posts, but using special include markup rather than direct php code
- Strange admin-ajax / CSS / $_SESSION issue
- WordPress search input in database, to edit information via form and update the database
- Remove a div class with condition
- Hooking into the HTML header container
- PHP Error message Upload images to remote server
- Block plugin update possibilities (but not by hiding notifications)
- WP_get_image_editor resizing images in a foreach loop
- Load my Inline js footer area
- CMB2 Output Select Box Chosen Option
- Soflyy WP All Import Custom File Download Issue
- WordPress Admin sub-level menu issue
- Custom User Notice Upon Login
- Add class as plugin for other plugins
- Displaying friend’s posts only
- How change menu for each user in plugin?
- Template from scratch: Sidebars not showing widget
- Contact Form 7: custom validation [closed]
- Enforce conditions only for draft posts using WyPiekacz, ignore pending and published posts
- Shortcode inside a redirect [closed]
- Attachement title in wpallimport
- Take Elementor For Email FIeld Check if user is registered. IF not registered then register on woocommerece
- Redirect a specific User role not admins automatically to view the post that they just updated