Automate spam/pending comments deletion in WordPress + bbPress

If you expose your bbPress forums to the public, it is likely you will be getting loads of spam every day. Most of it is actually caught either by WordPress itself, and set as pending, or by Akismet, and set as spam. Either way,

  1. bulk purging pending content is not possible from wp-admin; one needs to go through each page of comments individually.
  2. spam comments bulk removal can timeout wp-admin if you have many.

That is why it is best to schedule the deletion of spam and pending topics as a cron job. The following two commands will delete spam and pending topics for the previous week (not the current one, so there is some time to review them, if something legitimate is actually marked as spam). Just add them to cron (on Linux) through crontab -e (but care to change the --path value).

Doing the same for regular comments is unfortunately not possible, since WP-CLI does not support array input yet, so it is not possible to filter comments by date.

  • Was this Helpful ?
  • yes   no

Leave a Reply

Your email address will not be published. Required fields are marked *