Hi @Nick Loman:
There is not one command, but several. Be care though to back up your database before running this because there’s a tiny chance something in your database differs from mine, especially after a .1 upgrade beyond 3.0 and thus it may not work perfectly and you’ll have to restore.
DELETE FROM wp_usermeta WHERE user_id IN (
SELECT user_id FROM wp_comments WHERE user_id<>0 AND comment_approved='spam'
) AND user_id NOT IN (
SELECT DISTINCT user_id FROM wp_comments
);
DELETE FROM wp_users WHERE ID IN (
SELECT user_id FROM wp_comments WHERE user_id<>0 AND comment_approved='spam'
) AND ID NOT IN (
SELECT DISTINCT user_id FROM wp_comments
);
DELETE FROM wp_commentmeta WHERE comment_id IN (
SELECT comment_ID FROM wp_comments WHERE comment_approved='spam'
);
DELETE FROM wp_comments WHERE comment_approved='spam';
Related Posts:
- how to reduce the number of spam comments
- A spam bot loves me, what can I do?
- How to spam-filter a custom content type with the Akismet plugin?
- Getting trackback spam, even with trackbacks disabled
- How to block a someone from commenting?
- Reducing spammy user sign-ups
- How to reduce spam
- How do I permanently disable Pingbacks?
- What are all these spam subscribers doing here?
- How to disable WordPress trackbacks?
- How can I delete all my existing trackbacks?
- Comment Spammed vs Trashed
- Contact Form 7 being hijacked to send spam? [closed]
- getting casino links on my woocommerce site [closed]
- How to locate & delete hidden pages on a site
- How is my non-published blog getting so much spam?
- Contact Form 7 Plugin send emails to my Gmail as spam [closed]
- Automated spam being caught in 2 posts. Can this be used to help get rid of spam on everyone’s sites?
- WordPress Site has 35K spam images
- WordPress Phone Verification
- Is the tagline area spam-bot proof?
- Spam email sent from my [email protected] account
- How to block spam blocks pointing to a same website [closed]
- WordPress VPS out of Memory Problem
- Is it possible to determine proxy based comments?
- How to track down a phantom contact form?
- How to get rid of spam forever?
- Spams, Scams on WordPress site – what to do?
- Auto block ALL IP’s indicated by Akismet?
- Simple comments spam solution
- How to stop people from using my domain to send spam? [duplicate]
- WordPress and wamp sending “Delivery status notification Failure” to my inbox every 7 minutes
- Why do I get comment spam even with Akismet and Captcha?
- Removing the “Website” Field from Comments and Replies?
- What methods should be used to fend off splogs in a multiuser install? [closed]
- What’s the easiest way to close comments on media/attachments?
- How to remove comment spam in WordPress
- How is comment spam received without a comments form?
- How to prevent spam users registering even with registration disabled
- How exactly does Bad Behavior plugin work?
- Number of External Links in Comments – Moderation Option
- Comments screen in backend, how to disable Quick Edit | Edit | History | Spam | for non admins
- Check spam in custom form – akismet
- Mass delete spam accounts
- Akismet plugin is deleting spam despite preferences
- Hacked website redirect, only on desktop, help with restoring it [closed]
- How can I automatically delete comments that contain chinese / russian signs?
- Comments view limited to 20 results – any way to increase to 50 or 100?
- Remove default user registration, login and subscriber profiles
- How to expire all wordpress user passwords instantly?
- Report spam button
- wp_redirection_404 table has grown to 7GB
- How to bulk delete all WordPress subscribers?
- Bots posting comments on pages
- 14,000 WordPress Users. How did they get there?
- Invisible spam post in backend
- Auto delete WordPress users according to time
- How to make a secure blog that is completely private?
- Auto delete comment if Contains
- How do I programmatically set a user as spam in BuddyPress? [closed]
- All users/comments suspected as bot? [closed]
- Emails not getting delivered to Hotmail addresses
- Getting thousands of registration spam
- What do comments with […] mean?
- How to use a 3rd party library to send emails?
- oembed_cache SPAM problem [closed]
- How to find a spam link?
- UpdraftPlus installed malware – scared to download or update plugins now! [closed]
- How to Deny Access to No Referrer Requests on Multiste with Mapped domains
- CAPTCHA plugin where I can use my own images and ask my own questions? [closed]
- reCaptcha doesnt appear in comment (manual or plugin)
- Make every comment go to the spam folder
- Database hacked – random posts are modified
- Anonymous spam comments when only registered users can comment
- Has anyone developed a anti-spam plugin to simply allow users to BLOCK whatever they wish to, but one that will also go easy on IP addresses?
- How to add captcha to publish widget
- Prevent Registration Where Role is None?
- CPU overload spam – redirect link to wp-admin and new post
- WordPress site member verification emails going to spam on Outlook
- Getting hundreds of spam orders in WooCommerce with failed stripe payment [closed]
- How to prevent spams from admin-ajax.php file?
- Why does my admin email address keep changing to something random?
- Automatically reject a comment if website field contains anything
- how to prevent the spam on search function?
- Spam written by registred users
- Site has fake users registered with a similar pattern in username and email
- Prevent incoming $_GET requests
- Get Commentor IP When Marking Comment As Spam
- Hold a comment in the queue if it contains [X] or more links
- Prevent registration except through form
- Contact form spam, without form?
- Unwanted Links and Spam WordPress Pages and Posts
- approve,spam,trash etc. options are not coming on comments in admin panel
- Stop Authors from submitting spam post
- Adding a “Report the post” button/form?
- 404 Page when emptying spam or deleting a plugin
- comments are going to spam
- How to Prevent Unwanted Spam to Contact Form 7 [closed]
- How to hide and disable URL and email fields from comments?
- Dealing with HTTP w00tw00t attacks