How to bulk delete all WordPress subscribers?
I have 20,000 fake subscribers I'd like to get rid of. The admin panel only lets you delete 200 at a time.
How can I bulk delete all Wordpress subscribers via MySQL?
I have 20,000 fake subscribers I'd like to get rid of. The admin panel only lets you delete 200 at a time.
How can I bulk delete all Wordpress subscribers via MySQL?
You can use :
<?php
$blogusers = get_users( 'role=subscriber' );
// Array of WP_User objects.
foreach ( $blogusers as $user ) {
$user_id = $user->ID;
wp_delete_user( $user_id );
}
I ended up deleting all users who had not made a post using the following two queries:
First:
DELETE FROM wp_users
WHERE ID NOT IN (SELECT post_author FROM wp_posts)
Second:
DELETE
FROM wp_usermeta WHERE user_id NOT IN
(SELECT ID FROM wp_users)
Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.