benecaster_after_email_send
Fires after any Benecaster email send attempt completes. The $sent parameter indicates whether wp_mail() accepted the message for handoff to the mail server — true does not confirm delivery, only that the local handoff succeeded. If $sent is false, the benecaster_email_send_failed action will also fire with additional error context.
Use this hook for logging, analytics tracking, or post-send side effects that should run after every email regardless of type. A type-specific variant is available — append the email type to the hook name (e.g. benecaster_after_email_send_welcome) to target a single email type; the $email_type parameter is omitted on the type-specific variant. The type-specific variant fires automatically for custom email types — no extra wiring is needed. Stable built-in type strings are listed on the benecaster_after_email_send_type reference page.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$email_type |
string |
— | Email type string |
$recipient |
string |
— | Recipient email address |
$user_id |
int|null |
— | WordPress user ID, or null |
$show_id |
int|null |
— | Show ID, or null |
Examples
Track email sends in analytics
add_action( 'benecaster_after_email_send', function(
string $email_type,
string $recipient,
string $subject,
bool $sent,
?int $user_id,
?int $show_id
): void {
if ( ! $sent ) {
return; // wp_mail() handoff failed; wait for benecaster_email_send_failed
}
my_analytics_client()->track( 'email_sent', [
'type' => $email_type,
'recipient' => $recipient,
'show_id' => $show_id,
] );
}, 10, 6 );
Type-specific variant for welcome emails
// Fires only after welcome emails — $email_type is omitted
add_action( 'benecaster_after_email_send_welcome', function(
string $recipient,
string $subject,
bool $sent,
?int $user_id,
?int $show_id
): void {
// ...
}, 10, 5 );