Skip to main content

benecaster_email_subject

Filter Free

Filters the email subject line for any Benecaster email. A type-specific variant is available — append the email type to the hook name (e.g. benecaster_email_subject_welcome); the $email_type parameter is omitted on the type-specific variant.

Return a string. Cast with (string).

The subject arrives with its merge tags still in place ({{show_title}}, not the show’s title), and Benecaster fills them in after both filters have run. So a subject you return can carry {{tags}} of its own and they are filled in too. When your callback needs a tag’s value rather than its placeholder, read it from $tags, the last argument.

An empty tag leaves no gap: doubled spaces are collapsed, and a dash, colon or comma left dangling at either end is removed.

A type-specific variant, benecaster_email_subject_{$type}, runs immediately after and can overwrite this value. Its signature omits $type.

Parameters

Name Type Default Description
$subject string — Email subject line, with its merge tags not yet filled in
$email_type string — Email type string
$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
$tags array — The resolved merge tags, keyed by tag name without braces; values unescaped. Register the callback with 5 accepted arguments to receive it

Returns: string

Example

add_filter( 'benecaster_email_subject', function( $subject, $email_type, $user_id, $show_id ) {
    // Prefix episode notification subjects with the show name.
    if ( 'episode_notification' === $email_type && $show_id ) {
        $show_name = get_the_title( $show_id );
        $subject   = '[' . $show_name . '] ' . $subject;
    }
    return $subject;
}, 10, 4 );

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