Send episode notifications via custom webhook on publish
Fire a webhook — to a notification service, automation platform, or custom endpoint — the moment a new episode goes live. benecaster_episode_published fires at save_post priority 20, after the feed cache is cleared (priority 10), so the next feed request will already serve the new episode. Note: fires on every transition to ‘publish’, including re-publishing — check benecaster_episode_created if you need first-publish-only behaviour.
Code
<?php
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 );