Determining if an email was created by this plugin or not
-
Hello folks,
I was wondering if it was possible to determine if an email that is about to be sent was created by the Newsletter plugin or not. Is there a filter / hook I can use to check?
I have created a global email template for my WordPress site which is used every time WordPress sends an email. Now with the Newsletter plugin I’d like to check if the email is created by the plugin or not before applying my email template.
FYI, I’m using this code to apply my global email template to all emails and replace placeholders which I called [subject], [content] with the real email content.
function my_mail_template() { ob_start(); get_template_part('templates/email', 'template'); $output = ob_get_contents(); ob_end_clean(); return $output; } add_filter('wp_mail', 'my_mail_replace_placeholders'); function my_mail_replace_placeholders($atts){ $headers[] = 'From: My Website <[email protected]'; $headers[] = 'Content-type: text/html'; $atts['headers']= $headers; $template = my_mail_template(); $output1 = str_replace('[subject]', $atts['subject'], $template); $output2 = str_replace('[content]', $atts['message'], $output1); $atts['message'] = $output2; return $atts; }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Determining if an email was created by this plugin or not’ is closed to new replies.