benecaster_email_should_send
Controls whether a specific email is dispatched. Return false to suppress. IMPORTANT: Transactional emails (welcome, token_reset, billing receipts) should never be suppressed for compliance reasons — only suppress broadcast/marketing types. Type-specific variant: benecaster_email_should_send_{type} — 3 params, $email_type omitted.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$should_send |
bool |
— | Whether to send the email |
$email_type |
string |
— | Email type string (e.g. 'welcome', 'token_reset', 'broadcast') |
$user_id |
int|null |
— | WordPress user ID; null for admin-only emails |
$show_id |
int|null |
— | ID of the show; null when not show-specific |
Returns:
bool
Example
add_filter( 'benecaster_email_should_send', function( $should_send, $email_type, $user_id, $show_id ) {
// Suppress broadcast emails to users on a custom suppression list.
if ( 'broadcast' === $email_type && $user_id ) {
$suppressed = get_user_meta( $user_id, '_my_broadcast_suppressed', true );
if ( $suppressed ) {
return false;
}
}
return $should_send;
}, 10, 4 );