benecaster_episode_published
Fires when an episode’s post status transitions to publish. This hook fires on every publish transition — including when a previously unpublished episode is re-published after being drafted or trashed — and is distinct from benecaster_episode_created, which fires at first save regardless of status. Use this hook when you need to react to the moment an episode becomes publicly visible.
The feed cache is cleared at priority 10 before this hook fires at priority 20. By the time your callback runs the cache is already invalidated, so the next feed request will include the newly published episode.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$episode_id |
int |
— | ID of the episode post |
$show_id |
int |
— | ID of the parent show |
Examples
Send episode data to webhook on publish
add_action( 'benecaster_episode_published', function (
int $episode_id,
int $show_id
) {
$payload = [
'episode_id' => $episode_id,
'show_id' => $show_id,
'title' => get_the_title( $episode_id ),
'audio_url' => get_post_meta( $episode_id, '_benecaster_audio_url', true ),
'published_at' => get_the_date( 'c', $episode_id ),
];
wp_remote_post( 'https://hooks.example.com/new-episode', [
'body' => wp_json_encode( $payload ),
'headers' => [ 'Content-Type' => 'application/json' ],
'timeout' => 5,
] );
}, 10, 2 );
Notes
This hook fires on every publish transition, including re-publishes. If an episode is unpublished and then re-published, this hook fires again. To react only to first-ever publication, check whether benecaster_episode_created also fired in the same request (a transient keyed on the episode ID works well), or verify whether a publish date was previously set before this save.
Need this built rather than just documented? See our services →