'Wordpress SQL request to delete all user subscriber without publication

I have 3000 users and 2800 user without publication, so i want to delete all spam user with sql. thanks



Solution 1:[1]

Your question isn't very clear -

But if you mean "delete all users who have never posted anything" - Then

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

would do it... remember to back up your data first.

This will run through all the posts, make a list of the user IDs that ARE authors and then delete anyone who isn’t on the list from your wordpress users. Since custom post types are stored in wp_posts, it’ll be checking the author against all of those too.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Stender