MyBB Community Forums

Full Version: Delete all posts from unregistered users
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How can I delete all the posts from unregistered users?
I deleted their accounts but their posts are still here!!
You shouldn't have done that. Deleting accounts doesn't delete the user's posts. But you can't go back now. You can, however, run the following SQL queries to clean up the posts and threads of the users whose accounts you deleted. As always, taking a backup first is advised.

DELETE FROM  `mybb_posts` WHERE  `uid` =  '0' AND `username` != 'Guest';

DELETE FROM  `mybb_threads` WHERE  `uid` =  '0' AND `username` != 'Guest';

In the future please use the built in pruning system if you'd like to get rid of users who haven't posted or activated their account (among other options). This is located in Admin CP > Configuration > Settings > User Pruning. Configure things as you like and MyBB will take care of the rest via a task that is run every once in a while.
I realize that I shouldn't have done that now. Who would think that they'd leave part of the account. Like I wanted it ALL GONE therefor "DELETE".

You sure those queries are right? where udi = 0 and does not equal Guest or equal guest?
Yes, they are. I tested them myself. However it is still recommended to take a backup first.

uid=0 tests for posts whose author is unregistered. However guests are included in that group, so you also have to check for username != Guest to make sure guests are not affected (if you allow guests to post).
Oh, ok. That makes more sense. Thanks, will run them soon!