Here you will find all parameters supported by get_users()
.
$blogusers = get_users( [
'role' => 'subscriber',
// limit the number of rows returned
'number' => 100,
] );
foreach ( $blogusers as $user ) {
wp_delete_user( $user->ID );
}
Or return only ID:
// $blogusers is array of IDs
$blogusers = get_users( [
'role' => 'subscriber',
// return only user ID
'fields' => 'ID',
// limit the number of rows returned
'number' => 100,
] );
foreach ( $blogusers as $user_id ) {
wp_delete_user( $user_id );
}
Related Posts:
- Plugin Form Submission Best Practice
- WP 3.3 How to Add Menu Items to the Admin Bar?
- Plugin directory “Last Updated” not changed after initial commit?
- Unit tests – Dealing with dependencies
- What is the recommended way to create plugin administration forms?
- Should I create a theme or a plugin?
- How to check WordPress website username and password is correct
- How to sync with plugins update after I have done manual optimizations?
- How to retrieve a value via get_option when the option_value is stored in a multi-dimensional array?
- Custom theme sufficient or custom plugin neccessary for this feature set?
- How to change wordpress post title?
- Check spam in custom form – akismet
- Add Admin Menu Inside Construct or Init
- get plugin directory url
- How to properly modify get_userdata in plugin to get roles to update in database
- WordPress cron running twice
- How to create thumbnail of different files?
- Admin-ajax.php appending a status code to ajax response
- comment_email hook doesn’t seem to work for comment editor field
- How can I add a field to make link nofollow to the WordPress Link Inspector Window?
- Version upgrade: can my plugin filter the SQL statements issued during a database upgrade?
- admin_notices not displaying in plugin
- How to show large image in checkout page using WP Ecommerce plugin [closed]
- How to get color name in PanelColorSettings in custom Gutenberg block?
- Get Objects While Deleting term
- js/css updating when making a plugin
- settings_fields() doesn’t work for other roles except admin
- Subscribe to author?
- how to make custom bulk actions for a WP_List_Table (core class)
- Get name and email of current unregistered user, who has recently submitted name and email in comment form?
- Set page template programaticlly in plugin
- Auto save permalink setting page with the plugin activation
- creating custom function to log actions in plugin
- How to use output buffering in WordPress hooked functions?
- Plugin menu addition in multisite
- Show custom data instead of 404
- Mixing and Matching – Custom templates in a WordPress plugin
- What’s the right way to instantiate new blocks and/or the plugin itself in toto when using wppb architecture?
- Open Graph Object Debugger & url parameters – Page Not Found result
- How to get Metabox custom field to show checked if value is updated using post meta query?
- Serve text/html from wp-json API via WPEngine, headers not being set properly
- wp_schedule_event seems to be being added twice
- How to Move the Comments Bubble to the Right Side of the Toolbar
- How should I go about registering JavaScript that isn’t a file? [duplicate]
- What happens when two or more plugins use the same hook?
- Plugin is not generating title tags on any pages or posts
- How to pull user/author profile data in a plugin?
- Adding columns to core tables
- Run a function when new image is uploaded in media library
- Setting up Version Control for WordPress plugin development
- Ajax submit result opens in admin-ajax.php
- WordPress debug messages not displaying
- get author of published post
- Error passing post_content to function
- How to access all array values from do_action_ref_array()?
- Add a check box in Menu Settings
- How to register my code as a plugin
- Is there any way to fire heartbeat API from for website visitors?
- If $var is empty, return 404.
- Listing wordpress users with a search function
- Cannot stop wpautop from messing up my plug-in output
- How can I prevent ‘500 internal server error’ because of a long install process?
- dbdelta failing with error: “WordPress database error Table ‘wp_2_myPlugin’ already exists
- Update product prices from remote file
- Displaying custom content from a plugin within the active theme
- Using wp_mail to send email?
- Which wp plugin can use Create, Edit and Delete Email address from WordPress Dashboard
- product-attribute-slug-is-too-long-28-characters-max
- Custom plugin & calling REST api of wordpress instance the plugins is running on
- Add variables from rewrite rules to query var
- Limit get_next_post to posts from the same author
- Show list of categories that has posts with different taxonomies
- “add to cart” links css class “ajax_add_to_cart” doesn’t show in woocommerce in widget sidebar
- how to create a shortcode from a variable in plugin
- Any way, hook to add content right before the “read more” link?
- How do I specify where to save the debug.log?
- How do I ensure I can loop through every enqueued script and CSS?
- What is the source of the $post_id in a hook argument?
- WordPress Fatal error: Uncaught Error: Call to undefined function dbDelta()
- Plugins Settings page not updating
- TinyMCE 4.7.11 – Enable hidden WordPress core plugins? (referencing a wp-includes from plugin.php)
- Enqueue scripts based on site.
- My enqueue admin style function doesn’t work because of ?=ver
- Use content filter on the post that is password-protected
- WordPress filter custom posts by multi terms of of a taxonomy
- foreach argument to get specific file types getting too many returns
- How to fetch the post content from the wordpress editor before it can be saved(published)?
- How does one set cookies in WordPress without getting the ‘headers not sent’ error? within WP
- Filter the_content() to add custom figure tags
- Glyphicons Dont Show in WordPress Plugin Only
- Making plugin output customizable
- Return all roles, including custom roles
- Change the search results header from plugin
- Mapping multiple URLs to same page
- Installing plugins on installation/activation
- Add query string variables to all hyperlinks URL matching a specified domain
- Is there such a thing as a WordPress console?
- Loading jQuery library from WordPress admin
- Anyway to prevent admin from seeing other admin’s product?
- Programmatically creating posts based on external JSON feed (asynchronously)