Skip to main content

benecaster_sponsor_manager_sponsor_episodes

Filter Premium sponsor-manager

Filters what benecaster_sponsor_manager_get_sponsor_episodes() returns: a sponsor’s episodes, newest first, each [ 'episode_id' => int, 'show_id' => int, 'status' => string, 'positions' => string[], 'campaign' => array|null ]. The list already holds only episodes of shows where Sponsor Manager is on and the sponsor has a campaign; it may span several shows, so there is no show argument.

Parameters

Name Type Default Description
$episodes array — The sponsor's episodes as the function is about to return them
$sponsor_id int — The sponsor's post id

Returns: array

Example

// Keep published episodes only for every caller.
add_filter( 'benecaster_sponsor_manager_sponsor_episodes', function ( array $episodes, int $sponsor_id ): array {
    return array_values( array_filter( $episodes, fn( array $e ): bool => 'publish' === $e['status'] ) );
}, 10, 2 );

Notes

A return that is not an array is ignored. Walkthrough: Read an episode's sponsors, or a sponsor's episodes, from another add-on.

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