Add custom merge tags to all emails
Custom merge tags registered via benecaster_email_merge_tags are available in all Benecaster emails. With the Email Editor add-on active, these tags are also available in the drag-and-drop template builder — the same registration code unlocks them in both contexts without any additional steps.
Code
<?php
add_filter(
'benecaster_email_merge_tags',
function ( array $tags, string $type, int $user_id, int $show_id ): array {
$tags['show_manager_name'] = (string) get_post_meta( $show_id, '_my_addon_manager_name', true );
$tags['show_manager_email'] = (string) get_post_meta( $show_id, '_my_addon_manager_email', true );
$tags['episode_count'] = (string) wp_count_posts( 'benecaster_episode' )->publish;
return $tags;
},
10,
4
);