Skip to main content

benecaster_sponsor_manager_before_save_message

Action Premium sponsor-manager

Fires before a sponsor message is created or changed on the Sponsors screen’s Messages tab, or through POST /benecaster-sponsor-manager/v1/shows/{show_id}/messages or PUT, PATCH /benecaster-sponsor-manager/v1/shows/{show_id}/messages/{id}, once the request has validated. A message belongs to one show and never changes show.

Parameters

Name Type Default Description
$message_id int — The message being changed, or `0` before a create
$show_id int — The message's show
$fields array — What will be written, cleaned: `title`, `body` (HTML through `wp_kses_post`), `start_date`, `end_date` (`YYYY-MM-DD` or `''`) and `sponsor_id` (`0` for none). On a create, all five; on an update, only the keys sent

Example

add_action( 'benecaster_sponsor_manager_before_save_message', function ( int $message_id, int $show_id, array $fields ): void {
    my_audit_log( 'sponsor-message-saving', $message_id, $show_id, array_keys( $fields ) );
}, 10, 3 );

Notes

A refused request fires nothing; a write that then fails fires this hook alone. Walkthrough: Read or write a show's sponsor messages from code, as the Sponsors screen's Messages tab does.

Affects

  • Benecaster → Sponsors → Messages
  • POST benecaster-sponsor-manager/v1/shows/{show_id}/messages
  • PUT, PATCH benecaster-sponsor-manager/v1/shows/{show_id}/messages/{id}

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