Skip to:
Content
Pages
Categories
Search
Top
Bottom

Need to delete 27,000 spam forum posts


  • udidol
    Participant

    @udidol

    Hi,
    I have a bbpress forum on my website which was spammed with messages. There are 27,000 spam topics on it. I want to delete the forum entirely, but since there are so many topics, when I try to delete it the request gets timed out.

    I would like to delete most of the posts directly from the database with an SQL query. Can anyone provide an SQL query to delete these messages?

    As far as I could tell, all of the messages have the same title and same author name, if that helps (I didn’t look through all of the 27,000 posts).

    Any help is appreciated, thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

  • John James Jacoby
    Keymaster

    @johnjamesjacoby

    You won’t be able to do this with just 1 query, because you’ll also want to delete the associated meta-data; that will take at least another query with the post IDs of the topics you’re trying to delete. If you’re using any type of caching, those caches should be purged also, which usually requires PHP or a cache-key reset.

    There are a few alternatives.

    * Admin > Tools > Forums > Reset will let you erase all bbPress content completely. It may timeout depending on your server configuration, but it will eventually get through it.
    * Use WP-CLI: http://wp-cli.org
    * Export the DB, do the data delete on a more capable server (or locally) then re-import it back in. This obviously is the more technical solution, but works really well in a pinch.


    udidol
    Participant

    @udidol

    Thank you for your answer John,

    I would have reset the forums, but I have one forum that is untouched and which I want to keep. It is only one forum that was heavily spammed. I don’t see any way of getting all of the spam posts’ post ID…

    Exporting the database and performing the deletion locally sounds like a good option, but it will also require SQL queries, no? Also, is it not possible to write one query that deletes content from two tables (wp_posts and postmeta)?


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Also, is it not possible to write one query that deletes content from two tables (wp_posts and postmeta)?

    Correct; it is not possible. Each deletion from each table needs its own query. It’s not possible to know which meta-data IDs to delete without SELECTing which post IDs before deleting them.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar