benecaster_sponsor_manager_rest_sponsor
Filters each sponsor the Sponsors screen’s REST routes return (benecaster-sponsor-manager/v1/sponsors, a sponsor by id, and …/shows/{show_id}/sponsors): { id, company, contact_name, contact_email, notes, archived, shows }. The route adds campaigns (a read of one sponsor and every write) or campaign_status (a show’s list) after this filter, so neither is in $data; filter each campaign with benecaster_sponsor_manager_rest_campaign.
Admin-only data, but whatever you add is sent to the browser. It carries the contact’s email: never pass it to anything public.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$data |
array |
— | The sponsor as the route is about to return it |
$sponsor_id |
int |
— | The sponsor's post id |
Returns:
array
Example
// Add the sponsor's account manager to the Sponsors screen's data.
add_filter( 'benecaster_sponsor_manager_rest_sponsor', function ( array $data, int $sponsor_id ): array {
$data['account_manager'] = (string) get_post_meta( $sponsor_id, 'my_account_manager', true );
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 →