I have a site which have 90k+ user with subscriber roles.I want delete user with only subscriber role using phpmyadmin . So I know how to delete it But some users have multiple roles for example few users have both editor and subscriber role . Now my query is deleting all the user which subscriber roles including users which have multiple roles but I don't want that .So what should I update in my query to delete users which have only subscriber role. This is my current query

DELETE FROM  wp_users INNER JOIN wp_usermeta ON wp_users.ID = wp_usermeta.user_id WHERE meta_key = 'wp_capabilities'AND meta_value  LIKE '%subscriber% .

Any advice will be helpfull and thanks in advance and can anyone tell is this query also deleting fields in wp_usermeta right?

  • I'd avoid a diirect database query if I were you. Do you have access to the server via the terminal? Because you could then use WP CLI developer.wordpress.org/cli/commands/user/delete - e.g. wp user delete $(wp user list --role=subscriber --field=ID). Your query won't delete user meta or posts or anything related to the user in other tables.
    – Paul
    Jul 29, 2022 at 6:50
  • Will this command delete user with only subscriber role ? And will this also delete meta?
    – RDX023
    Jul 29, 2022 at 13:08
  • Unfortunately, it would also delete users with multiple roles, I just did a quick test. You'll probably need a custom CLI command. I'll try and find some time to write one
    – Paul
    Jul 29, 2022 at 16:30
  • Aah ok thanks is there any plugin which can do this ?
    – RDX023
    Jul 31, 2022 at 3:46

1 Answer 1


Here's a plugin

Please run with --dry-run first and also do a full database backup!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.