Skip to content

Instantly share code, notes, and snippets.

@yuriinalivaiko
Created March 12, 2024 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuriinalivaiko/61e025eaa52eb83cc33a42e51240e114 to your computer and use it in GitHub Desktop.
Save yuriinalivaiko/61e025eaa52eb83cc33a42e51240e114 to your computer and use it in GitHub Desktop.
Add custom email placeholders
<?php
// Add role-specific content to the email template.
add_filter( 'um_template_tags_patterns_hook', 'my_template_tags_patterns', 10, 1 );
add_filter( 'um_template_tags_replaces_hook', 'my_template_tags_replaces', 10, 1 );
function my_template_tags_patterns( $search ) {
$search[] = '{welcome_content_for_subscriber}';
$search[] = '{welcome_content_for_customer}';
$search[] = '{welcome_content_for_um_member}';
return $search;
}
function my_template_tags_replaces( $replace ) {
$role = um_user( 'role' );
$replace[] = 'subscriber' === $role ? 'This message is shown in the welcome email for users whose priority user role is "Subscriber".' : '';
$replace[] = 'customer' === $role ? 'This message is shown in the welcome email for users whose priority user role is "Customer".' : '';
$replace[] = 'um_member' === $role ? 'This message is shown in the welcome email for users whose priority user role is "Member".' : '';
return $replace;
}
@yuriinalivaiko
Copy link
Author

yuriinalivaiko commented Mar 12, 2024

This code is an example for the Ultimate Member plugin.

Related documentation: Emails Tab, Placeholders for email templates

See details here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment