benecaster_after_broadcast_send
Fires once per broadcast, when every recipient has been handed to the email queue or refused. It fires from the WP-Cron batch that handles the last recipient, not in the request that called benecaster_send_broadcast(), which has already returned.
It fires exactly once, also when a batch was interrupted and picked up again, and also for a broadcast whose show was trashed part-way through: the recipients not yet reached count as skipped. As with benecaster_after_email_send, sent means queued; delivery happens later, from the queue.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$broadcast_id |
int |
— | The broadcast's id |
$show_id |
int |
— | ID of the show the broadcast is from |
$counts |
array |
— | `recipients` (everyone the audiences reached), `queued` (handed to the queue), `suppressed` (refused by their opt-out or by [benecaster_email_should_send](/hooks/benecaster_email_should_send/)) and `skipped` (no email address, or the send could not be queued) |
Examples
Tell the podcaster a broadcast has been queued
add_action( 'benecaster_after_broadcast_send', function ( int $broadcast_id, int $show_id, array $counts ): void {
wp_mail(
get_option( 'admin_email' ),
'Broadcast queued',
sprintf( '%d of %d listeners queued; %d opted out.', $counts['queued'], $counts['recipients'], $counts['suppressed'] )
);
}, 10, 3 );
Notes
Register your listener when your plugin loads, on plugins_loaded or benecaster_boot. One added next to the benecaster_send_broadcast() call is gone by the time this fires, because it fires in a later request.
Need this built rather than just documented? See our services →