One friend of mine asked me how to remove around 16,000 spam users with Role of “None”.

I tried several methods which includes:

  • Remove Users with Role “None”
  • Remove Users with Role “NULL”
  • Sort users in admin dashboard via Role (So I can bulk delete)

None of them works, till found this snippet

delete from wp_users where ID not in
(select user_id from wp_usermeta where meta_key = 'wp_capabilities')

delete from wp_usermeta where user_id not in
(select ID from wp_users)

You can excute the snippet from phpMyAdmin or using this plugin: https://wordpress.org/plugins/run-sql-query/

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x