Is it possible to add customization in functions.php to change the email template based on the value of the autotags in wordpress?
Here’s the code I used for Mandrill, appreciate help in transitioning to SparkPost.
/* Set Mandrill Template */
function changeMandrillTemplate($message) {
// convenience variable
$autoTags = $message['tags']['automatic'];
// Is it an Ambassador Program email? //
// Is it a Contact Form email? //
if (strpos(implode(',', $autoTags),'wp_WPCF7_Mail') !== false) {
$message['template']['name'] = 'contact-template';
}
// Is it a Wordfence email? //
elseif ( (strpos(implode(',', $autoTags),'wp_wordfence') !== false) or (strpos(implode(',', $autoTags),'wp_wf') !== false)
or (strpos(implode(',', $autoTags),'wp_WP_Automatic_Updater') !== false) ) {
$message['template']['name'] = 'admin-template';
}
// Is it a new user email? //
elseif (strpos(implode(',', $autoTags),'wp_newuser_notify_siteadmin') !== false) {
$message['template']['name'] = 'admin-template';
}
// General Template Specified in Plugin Settings //
return $message;
}
// Don't forget to register the filter!
add_filter('mandrill_payload', 'changeMandrillTemplate');
/* Convert All Double Line Breaks to html Paragraph Tags */
function op_mandrill_payload($message) {
// Add wpautop to message content
$message['template']['content'][0]['content'] = wpautop($message['template']['content'][0]['content']);
return $message;
}
add_filter('mandrill_payload', 'op_mandrill_payload');