«
»

Permanently remove deleted posts and topics in bbPress

April 7th, 2010 by George Notaras

Permanently removing deleted posts and topics in bbPress can be cumbersome. bbPress does not provide a decent way to completely remove deleted content from the database. I am not sure why… In my case, these posts mostly contain spam and there is absolutely no reason to keep them in the database any more. As it usually happens when I try to administer bbPress, I ended up executing SQL queries at the MySQL prompt. I hereby publish these SQL statements.

First delete all posts in deleted topics:

DELETE FROM bb_posts WHERE post_id IN (
    SELECT post_id FROM (
        SELECT DISTINCT(p.post_id)
        FROM bb_posts AS p LEFT JOIN bb_topics AS t ON p.topic_id=t.topic_id
        WHERE t.topic_status=1
    ) AS bb_posts_in_deleted_topics
);

Then remove all deleted posts:

DELETE FROM bb_posts WHERE post_status=1;

Finally, remove all deleted topics:

DELETE FROM bb_topics WHERE topic_status=1;

In the bbPress administration panel, you can now use the “Tools” section to recount posts.

The Permanently remove deleted posts and topics in bbPress by George Notaras, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Terms and conditions beyond the scope of this license may be available at www.g-loaded.eu.

Related Articles

Tags: , ,

Bookmark and Share

Comments are automatically disabled after a certain period of time. Further discussion about the published content is still possible though in the G-Loaded Forums.