We have more than 900.000 spam users! and they haven't any role. We want to delete all spam users and their meta.
In this answer and this link we can delete users based on role but our spam users doesn't have any role.
This query return real users:
SELECT user_id FROM wp_usermeta WHERE meta_key = 'wp_capabilities'
In usermeta
spam users doesn't have capabilities
key.
We want remove spam users with database query.
One method to delete several users simultaneously is by viewing them in the admin panel and then selecting them for deletion. In this method, you don't have to install any new plugins or make major alterations to the website. It's perhaps one of the easiest ways to bulk delete WordPress users quickly.
To bulk delete usersOpen the CSV file and add a line for each user you want to delete. The only required value is User principal name. Save the file. On the Bulk delete user page, under Upload your csv file, browse to the file.
Deleting usersLog in as admin, then navigate to your dashboard. From the dashboard, select Users > All Users. Locate the desired user, then click Delete. Confirm when prompted.
Upon activation, you need to visit Bulk WP » Bulk Delete Users page. Here you can select Bulk Delete options for deleting users. First, you can select the specific user roles. After that you can select the filtering options.
for resolve you can use subquery and in operator
delete from wp_users where ID not in
(select user_id from wp_usermeta where meta_key = 'wp_capabilities')
select user_id from wp_usermeta where user_id not in
(select ID from wp_users)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With