0

I need to clean a WordPress Web site of SPAM users. I checked the Users list and noticed that valid users have a proper Name listed; SPAM users do not have that value and a - is displayed instead. How do I delete all users with a - posted under the Name field in Wordpress Admin? Preferable, i would rather use thr MySQL Database to do this, but if it is too risky, deleting from Admin is okay, but very slow navigating through each screen, etc.

Tks for your feedback.

  • How many users? – Andy Macaulay-Brook Mar 16 at 15:36
  • A - is in Username or Nickname field in dashboard? – nmr Mar 16 at 16:26
1

Replace the prefix in wp_users and wp_usermeta table names for the one you use.
Make backup of data from both tables before you start to delete users.

DELETE u FROM wp_users u
  LEFT JOIN wp_usermeta um1 ON u.id = um1.user_id AND um1.meta_key = 'first_name'
  LEFT JOIN wp_usermeta um2 ON u.id = um2.user_id AND um2.meta_key = 'last_name'
WHERE (um1.meta_value IS NULL OR CHAR_LENGTH(um1.meta_value) = 0)
  AND (um2.meta_value IS NULL OR CHAR_LENGTH(um2.meta_value) = 0);

DELETE um FROM wp_usermeta um
  LEFT JOIN wp_users u ON u.id = um.user_id 
WHERE u.id IS NULL;
  • Thank You; that worked very nicely. Now, I just need to find a way to keep SPAM users from registering and filling-up my database. – Johnny Mar 16 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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