benecaster_sponsor_manager_rest_campaign
Filters each sponsor campaign the Sponsors screen’s REST routes return (benecaster-sponsor-manager/v1/shows/{show_id}/campaigns), and each campaign in a sponsor’s campaigns list: { id, sponsor_id, show_id, name, start_date, end_date, currency, rate_type, rate_by_position, rate_minor, rates, archived, status, sponsor }. In a sponsor’s list, show_title is added after this filter.
Admin-only data, but whatever you add is sent to the browser. It carries the agreed rate: never pass it to anything public.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$data |
array |
— | The campaign as the route is about to return it |
$campaign_id |
int |
— | The campaign's id |
Returns:
array
Example
// Add an insertion-order number kept by your own plugin.
add_filter( 'benecaster_sponsor_manager_rest_campaign', function ( array $data, int $campaign_id ): array {
$data['insertion_order'] = my_plugin_insertion_order( $campaign_id );
return $data;
}, 10, 2 );
Notes
A return that is not an array is ignored. Walkthrough: Read, create, change, archive or restore the site's sponsors and a show's sponsor campaigns from code, as the Sponsors screen does.
Affects
- Benecaster → Sponsors
Need this built rather than just documented? See our services →