Flush full-page caches when a per-show Supporter Wall is enabled or disabled
Turning a show’s Supporter Wall on or off changes what its public pages contain. Under a full-page cache, those pages keep serving the old version — a wall that is switched on but invisible, or one switched off and still showing supporters who have just been removed from it. The second is the one that matters: it is a privacy setting that appears not to have taken effect.
benecaster_supporter_wall_enabled and benecaster_supporter_wall_disabled fire on that change and are the moment to flush the affected pages.
They are two separate events so you can listen to only the direction you care about — flushing on disable is the urgent one — and neither fires when a save leaves the setting where it already was, so your callback runs once per real change rather than once per visit to the settings screen.
Code
<?php
function bc_flush_supporter_wall_pages( int $show_id ): void {
// Generic WP transient + page-cache plugin hooks.
delete_transient( 'my_theme_supporter_wall_' . $show_id );
// Common page-cache plugins.
if ( function_exists( 'wp_cache_clear_cache' ) ) { wp_cache_clear_cache(); } // WP Super Cache
if ( function_exists( 'rocket_clean_post' ) ) { rocket_clean_post( $show_id ); } // WP Rocket
}
add_action( 'benecaster_supporter_wall_enabled', 'bc_flush_supporter_wall_pages' );
add_action( 'benecaster_supporter_wall_disabled', 'bc_flush_supporter_wall_pages' );
Hooks Used
Need this built rather than just documented? See our services →