How to create custom email tags

1. Register your custom tag

To register a new email tag you will need to use the wpum_email_tags filter. This code can be added to your theme's functions.php

function wpum_my_email_tag( $tags, $emails ) {

	$tags[] = array(
		'name'        => 'Tag name',
		'description' => 'description goes here',
		'tag'         => 'your_tag',
		'function'    => 'my_email_tag_function'

	return $tags;
add_filter( 'wpum_email_tags', 'wpum_my_email_tag', 10, 2 );

In the above example we've registered a new tag called "Tag name", the tag that will then be used within the email is "your_tag". The function parameter sets the name of the function that will be used to manipulate the output of the tag within the emails. The next step is to create a function with the name specified above.

2. Define the output of the custom tag

The function that handles the output of the tag, takes 1 parameter -> $user_id which can be used to retrieve content related to the user.
In the following example we're going to retrieve the content of a custom meta field called "wpum_field_11".
function my_email_tag_function( $user_id ) {

	return get_user_meta( $user_id, 'wpum_field_11', true );


3. Add the tag to the emails content

Now that you're registered the tag and created the output of the tag, you'll find the new tag within the emails editor. Edit your emails and add {your_tag} to your emails. The tag will now display the content that you defined with your custom function.