How to Completely Uninstall bbPress 2

bbPress has been around for a while, but when version 2 was released back in September 2011, it brought something entirely new to the table; it was no longer standalone software, but a plugin that fully integrates the forums into your WordPress installation. This is great on many levels, but it can be a nightmare if you need to remove bbPress, as I discovered.

A client of mine wanted to ditch their old phpBB forums in return for the fully integrated goodness of bbPress. The first battle, was figuring out how to get all of the users, topics, and replies over to the WP database. After many failed attempts by clunky forum conversion plugins, I found success with bbConverter. Although, as we quickly discovered, it too has its own flaws; we were left with 40k topics and 120k replies, but many had authors mixed up, were in the wrong place, or no longer belonged to a forum. Not to mention, bbConverter didn’t convert any of the bbCode used by phpBB, and didn’t do anything with file attachments. In short, the converted forums were a bloody mess and hardly useable. After a few days of trying to make the best of the situation, we decided to roll back and stick with phpBB.

Now I was faced with the task of cleaning up the database and removing the bbPress content. Surprisingly, there is no “uninstall” for bbPress, so I knew it was going to be a manual task. After digging through the database, I found that topics and replies are custom post types, which means they’re now part of the wp_posts table, where as all bbPress tables were previously independent, and prefixed with bb_. It’s not as simple as dropping a handful of tables and calling it a day. Topics and replies (and likely forums; I deleted them from WP-Admin as there was less than 20) are mixed in with the main posts, and other custom post types the site uses.

After half an hour of Googling, I found a solution on Stack Exchange. The only thing I had to do, was replace “customposttype” with the actual post type names, and change the table prefix (as it’s not the WP default).

Be sure to backup your database before running the following queries.

DELETE a,b,c FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID=b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID=c.post_id)
WHERE a.post_type='topic'
DELETE a,b,c FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID=b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID=c.post_id)
WHERE a.post_type='reply'

Those two queries cleared out the over 160k records found in the _posts table, and the associated data stored in the _postmeta and _term_relationships tables.