Remove posts with category (or categories) from BuddyPress Activity Stream

This was tricky and took me several attempts to figure out how to gracefully remove posts in a specified category from the public BuddyPress Activity Stream. Proposed solutions took the approach of stopping the activity from being added to the table; however, this raised issues when an existing post was updated and put in the excluded category, and also when an excluded post was updated to no longer be in the excluded category. Additionally, these posts were not included in the author’s individual Activity Stream, which led to further confusion.

I had to move `bp_blogs_record_post` from `save_post` to `wp_insert_post` to allow `_save_post_hook` to clean the post cache prior to running `in_category()`.

Leave a Reply