Skip to main content

benecaster_episode_meta_updated

Action Free Since v1.0.0

Fires after episode meta is saved via the Benecaster REST API, providing a before-and-after diff of every tracked meta key that changed. Only fires when at least one tracked key differs from its stored value — does not fire when nothing changed.

This hook complements [benecaster_episode_updated](/hooks/benecaster_episode_updated/), which covers only post-table columns (`title`, `post_status`, `post_date`, and similar). Use [benecaster_episode_meta_updated](/hooks/benecaster_episode_meta_updated/) when you need to react to changes in audio URLs, descriptions, episode numbers, artwork, guests, or any other `_benecaster_*` meta field. The `$changed_meta` array is keyed by meta key; each value is an associative array with `old` and `new` sub-keys. Only changed keys are included. Note: this hook only fires for saves made through the Benecaster REST API — direct `update_post_meta()` or `wp_update_post()` calls from other code do not trigger it.

Parameters

Name Type Default Description
$episode_id int ID of the episode post
$show_id int ID of the parent show
$changed_meta array Associative array of changed meta keys; each value is {old: $old_value, new: $new_value}

Examples

Sync audio URL and description changes

add_action( 'benecaster_episode_meta_updated', function (
    int   $episode_id,
    int   $show_id,
    array $changed_meta
): void {
    $fields_of_interest = [
        '_benecaster_audio_url',
        '_benecaster_description_rss',
        '_benecaster_episode_type',
    ];

    $relevant = array_intersect_key( $changed_meta, array_flip( $fields_of_interest ) );
    if ( empty( $relevant ) ) {
        return;
    }

    $payload = [ 'episode_id' => $episode_id ];
    foreach ( $relevant as $key => $diff ) {
        $short_key             = str_replace( '_benecaster_', '', $key );
        $payload[ $short_key ] = $diff['new'];
    }

    wp_remote_post( 'https://api.example.com/episodes/sync', [
        'body'    => wp_json_encode( $payload ),
        'headers' => [ 'Content-Type' => 'application/json' ],
        'timeout' => 5,
    ] );
}, 10, 3 );

Notes

Only fires for episode saves made through the Benecaster REST API (PUT /benecaster/v1/episodes/{id}). Direct update_post_meta() or wp_update_post() calls do not trigger this hook — use WordPress core's updated_post_meta action for those cases. Only meta keys tracked by Benecaster appear in $changed_meta.