benecaster_send_webhook_event()
benecaster_send_webhook_event( string $addon_slug, string $event, int $show_id, array $data = [], int $user_id = 0 ): int
Queues one delivery of an add-on event on the podcaster’s webhook. The body is event, delivery_id, source (your add-on’s catalog slug), schema_version (from registration), show_id, then — only when $user_id is a real user — user_id and email, then the keys of $data, then occurred_at. Sending happens later from the queue, never inside the request that called this.
Put your add-on’s own record ID in the body, as {noun}_id (for example guest_id). A receiver that later calls back in through an integration action needs it to say which record it means.
The body passes through benecaster_webhook_payload like Benecaster’s own events, with $payload['source'] set to your slug.
Parameters
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
addon_slug |
string |
— | Yes | The slug your add-on registered with; either form works. |
event |
string |
— | Yes | An event this add-on registered with benecaster_register_webhook_event(). |
show_id |
int |
— | Yes | The show the event happened on. |
data |
array |
[] |
No | Your own keys for the body. Keep it JSON-serialisable. |
user_id |
int |
0 |
No | The WordPress user involved, or 0 when none is. |
Return Value
Type:
int
The queued delivery's ID, or 0 when nothing was queued.
Example
add_action( 'my_workflow_guest_booked', static function ( int $guest_id, int $show_id ): void {
benecaster_send_webhook_event( 'podcast-workflow', 'podcast-workflow.guest.booked', $show_id, [
'guest_id' => $guest_id, // your record id, as {noun}_id
'guest_name' => get_the_title( $guest_id ),
] );
}, 10, 2 );
Hooks Fired
Notes
Nothing is queued when the event was not registered by this add-on (also reported with _doing_it_wrong() — a programming error); your add-on is not active on $show_id (not granted to the show's license, or switched off for the show — silently, since that is a normal state); the webhook is switched off or has no URL or secret; the site is a staging copy; or benecaster_webhook_payload returned null. You never need your own benecaster_addon_is_active() check around it.
$data cannot overwrite the reserved keys listed above: a reserved key in $data is dropped and reported with _doing_it_wrong().
The add-on check is made once, when the event is queued. A delivery queued while your add-on was active still goes out, retries included, if the license lapses before it is sent.
Need this built rather than just documented? See our services →