My user database is full up with robots. Is there a useful SQL command to delete all the users that either a) have posted a comment marked as spam by Akismet or b) never posted a comment ?
Leave a Reply
You must be logged in to post a comment.
My user database is full up with robots. Is there a useful SQL command to delete all the users that either a) have posted a comment marked as spam by Akismet or b) never posted a comment ?
You must be logged in to post a comment.
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.
You’ll want to use the wp_delete_user() function:
http://codex.wordpress.org/Function_Reference/wp_delete_user
However, first you need all the user ids to delete. I’d suggest getting them by doing something like the following (note: this code is not tested):
I would suggest running the query manually and spot checking the results before doing any deletions. And, of course, back up your database before making any changes.