Skip to main content

benecaster_clear_feed_cache

Action Premium

Triggers a Benecaster feed cache clear. Use do_action() to request a clear — this hook acts as a command. Three scoping levels are available:

do_action( 'benecaster_clear_feed_cache' );                       // global
do_action( 'benecaster_clear_feed_cache', $show_id );             // show-scoped
do_action( 'benecaster_clear_feed_cache', $show_id, $tier_slug ); // tier-scoped

Use this hook when your code modifies episode data, tier assignments, or show metadata through a path outside Benecaster’s standard write endpoints — for example a WP-CLI import script, a webhook handler, or a migration plugin. When changes happen through the episode editor, the REST API, or the Settings UI, Benecaster invalidates the cache automatically. Prefer the narrowest scope that covers your change: on a large multi-show site, a global clear triggers a wave of feed rebuilds on the next subscriber poll. This is a Premium hook.

Parameters

Name Type Default Description
$show_id int Optional. Omit to clear every show
$tier_slug string Optional. Omit to clear every tier of $show_id

Examples

Clear cache after bulk episode import

// Clear all tier caches for show ID 42 after a bulk import.
do_action( 'benecaster_clear_feed_cache', 42 );

Clear a single tier after availability update

do_action( 'benecaster_clear_feed_cache', $show_id, 'premium' );

Notes

Calling add_action() on this hook runs your callback as part of the clear pipeline — before cache entries are removed. This is rarely needed but available for pre-clear side effects. Redundant calls on already-empty or already-stale cache entries are no-ops with no harmful effect beyond minor overhead. A tier-scoped clear is faster than a show-scoped clear, which is faster than a global clear.

Core also fires the show-scoped form itself whenever a built-in membership tier is created, deleted, or updated in any column other than its Stripe product IDs (MembershipTierRepository, since bugfix/feed-tier-cache-and-namespace-docs). That table is not part of the feed cache key, so a tier reorder would otherwise leave stale tier-dependent XML for up to 24 hours. A benecaster_feed_cache_cleared listener therefore sees a 'show' clear on each such tier edit — one per tier when a reorder saves several tiers.

Need this built rather than just documented? See our services →