Skip to main content

benecaster_email_merge_tags

Filter Free

The primary developer hook for registering custom merge tags. Fires at render time, per recipient. The tags array is pre-populated with global tags (subscriber name, email, show title, RSS URL, unsubscribe URL, site name, year) and email-type-specific initial tags. Add keys to introduce new tag → value substitutions.

A type-specific variant is available — append the email type to the hook name (e.g. benecaster_email_merge_tags_welcome) to target a single type; the email type parameter is omitted, and the type-specific variant fires immediately after the shared filter.

Parameters

Name Type Default Description
$tags array Array of {tag => value} pairs; pre-populated with global and type-specific tags
$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

Returns: array

Example

add_filter( 'benecaster_email_merge_tags', function( $tags, $email_type, $user_id, $show_id ) {
    // Add a {{member_since}} tag showing when this subscriber joined.
    if ( $user_id && $show_id ) {
        $joined = get_user_meta( $user_id, '_benecaster_joined_' . $show_id, true );
        if ( $joined ) {
            $tags['member_since'] = date_i18n( get_option( 'date_format' ), strtotime( $joined ) );
        }
    }
    return $tags;
}, 10, 4 );

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