benecaster_sponsor_manager_before_save_episode_sponsors
Fires before an episode’s sponsor list is 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. 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 about to be 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 is removed or none is kept on a move |
$previous |
array |
— | The list stored until now, in the same shape |
Example
add_action( 'benecaster_sponsor_manager_before_save_episode_sponsors', function ( int $episode_id, int $show_id, array $sponsors, array $previous ): void {
my_audit_log( 'episode-sponsors-saving', $episode_id, count( $previous ), count( $sponsors ) );
}, 10, 4 );
Notes
A refused request fires nothing, and 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 →