Skip to main content

benecaster_sponsor_manager_after_save_episode_sponsors

Action Premium sponsor-manager

Fires once an episode’s sponsor list has been saved from the episode editor’s Sponsors tab or through PUT /benecaster-sponsor-manager/v1/shows/{show_id}/episodes/{episode_id}/sponsors, and when an episode moves to another show. It fires only when the write succeeded. On a move, each sponsor with an active campaign on the destination show covering the episode’s date is kept and re-pointed to that campaign (the newest-starting when several do), and every other sponsor is dropped.

Parameters

Name Type Default Description
$episode_id int — The episode
$show_id int — The episode's show; on a move, the show it moved to
$sponsors array — The list stored, in order: `[ [ 'sponsor_id' => int, 'campaign_id' => int, 'positions' => string[] ], … ]`. `campaign_id` `0` is no campaign; `positions` holds `pre_roll`, `mid_roll`, `post_roll` in that order. `[]` when every sponsor was removed or none was kept on a move
$previous array — The list stored before, in the same shape

Example

// Tell an ad-ops sheet whenever an episode's sponsor line-up or campaigns change.
add_action( 'benecaster_sponsor_manager_after_save_episode_sponsors', function ( int $episode_id, int $show_id, array $sponsors, array $previous ): void {
    $before = array_column( $previous, 'campaign_id', 'sponsor_id' );
    foreach ( $sponsors as $entry ) {
        if ( ( $before[ $entry['sponsor_id'] ] ?? null ) !== $entry['campaign_id'] ) {
            my_adops_log( $show_id, $episode_id, $entry['sponsor_id'], $entry['campaign_id'] );
        }
    }
}, 10, 4 );

Notes

Sending the list already stored writes nothing and fires nothing. A move fires it with Sponsor Manager off on every show too; moving an episode with no sponsors fires nothing. Deleting an episode for good removes its sponsors without firing it. Walkthrough: Read or set an episode's sponsors, the campaign each is tied to, and their ad positions from code, as the episode editor's Sponsors tab does.

Affects

  • Episode editor → Sponsors
  • PUT benecaster-sponsor-manager/v1/shows/{show_id}/episodes/{episode_id}/sponsors

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