Skip to main content

benecaster_sponsor_manager_rest_message

Filter Premium sponsor-manager

Filters each sponsor message the Messages tab’s REST routes return (benecaster-sponsor-manager/v1/shows/{show_id}/messages, a message by id, its writes, and the Recently expired list): { id, show_id, title, body, start_date, end_date, sponsor_id, archived, status, shortcode, sponsor }.

Admin-only data, but whatever you add is sent to the browser. It changes what the routes return, never what the message’s tag shows: filter that with benecaster_sponsor_manager_message_output.

Parameters

Name Type Default Description
$data array — The message as the route is about to return it
$message_id int — The message's id

Returns: array

Example

// Add the read length an ad-sales tool works from.
add_filter( 'benecaster_sponsor_manager_rest_message', function ( array $data, int $message_id ): array {
    $data['word_count'] = str_word_count( wp_strip_all_tags( $data['body'] ) );
    return $data;
}, 10, 2 );

Notes

Affects

  • Benecaster → Sponsors → Messages

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