Intermittent 404 errors, rewrite rules, and BBPress

There’s a known issue with LearnDash and bbPress/BuddyPress which can cause this, I ran into the same thing myself. Maddening! And it’s proportional to the number of BP events being generated so the more user activity you have, the more it occurs. Details in the LearnDash support site here.

I used the following code to fix:

// Fix for LearnDash causing 404s on BuddyPress activity (updates, messages)
add_filter( "learndash_flush_rewrite_rules", function( $flush, $post_options ) {
return true;
}, 4, 2 );