benecaster_sponsor_manager_before_save_sponsor
Fires before a sponsor is created or changed on the Sponsors screen, or through POST /benecaster-sponsor-manager/v1/sponsors or PUT, PATCH /benecaster-sponsor-manager/v1/sponsors/{id}, once the request has validated. A sponsor is one record for the whole site, so a change here applies on every show the sponsor has campaigns on.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$sponsor_id |
int |
— | The sponsor being changed, or `0` before a create |
$fields |
array |
— | The keys sent, cleaned: `company`, `contact_name`, `contact_email` (lowercased), `notes`. On a create, every key, with `''` for those not sent |
Example
add_action( 'benecaster_sponsor_manager_before_save_sponsor', function ( int $sponsor_id, array $fields ): void {
my_audit_log( 'sponsor-saving', $sponsor_id, array_keys( $fields ) );
}, 10, 2 );
Notes
A refused request fires nothing; a write that then fails fires this hook alone. $fields holds the contact's email: never pass it to anything public. 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
- POST benecaster-sponsor-manager/v1/sponsors
- PUT, PATCH benecaster-sponsor-manager/v1/sponsors/{id}
Need this built rather than just documented? See our services →