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?

Solutions Collecting From Web of "How to bulk delete all WordPress subscribers?"

I ended up deleting all users who had not made a post using the following two queries:


DELETE FROM wp_users
WHERE ID NOT IN (SELECT post_author FROM wp_posts)


FROM wp_usermeta WHERE user_id NOT IN
(SELECT ID FROM wp_users)

You can use :

$blogusers = get_users( 'role=subscriber' );
// Array of WP_User objects.
foreach ( $blogusers as $user ) {
    $user_id = $user->ID;
    wp_delete_user( $user_id );