benecaster_episode_unpublished
Fires when an episode’s post status transitions away from `publish` — whether the episode is moved to trash, reverted to draft, or set to private. Common transitions that trigger this hook: publish → trash, publish → draft, publish → private.
The episode still exists in the database when this hook fires — `get_post()`, `get_the_title()`, and `get_post_meta()` all return valid data, and the post status reflects the new non-published value. This hook does not fire when an episode is permanently deleted; use [benecaster_episode_deleted](/hooks/benecaster_episode_deleted/) for that case.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$episode_id |
int |
— | ID of the episode post |
$show_id |
int |
— | ID of the parent show |
Examples
Purge CDN and remove from search index
add_action( 'benecaster_episode_unpublished', function (
int $episode_id,
int $show_id
) {
// Purge the episode's CDN cache so the locked-content page is served.
my_cdn_purge_url( get_permalink( $episode_id ) );
// Remove from search index.
my_search_index_delete( $episode_id );
}, 10, 2 );
Notes
This hook fires when an episode is moved to the WordPress Trash (publish → trash transition). Permanent deletion — emptying the trash or force-deleting — fires benecaster_episode_deleted instead, not this hook. Pair this hook with benecaster_episode_published to keep external systems synchronized with episode visibility state. This is a Free hook — it fires regardless of license status. This hook is registered on save_post at priority 20.