Multisite + wp_mail + conditional email templates
-
Hi there,
I’m using your plugin in a multisite environment.
My use case:
- On
save_post
… - I want to send an email to “User A” via “Site 1”
- I want to send an email to “User B” via “Site 2”
- I want each site’s respective email template from your plugin to be recognized (currently, only the child site’s template is recognized’
My code:
function conditional_multisite_wp_mail( $post_id, $post, $update ) {$to1 = ‘[email protected]’;
$to2 = ‘[email protected]’;
$subject1 = ‘SPECIFIC: testing right meow’;
$subject2 = ‘CURRENT: testing right meow’;
$message = ‘woof’;
$headers1 = ‘From: Derp < [email protected] > \r\n’;
$headers2 = ‘From: Herp < [email protected] > \r\n’;
switch_to_blog(2); // Switch to specific site
wp_mail( $to1, $subject1, $message, $headers1, $attachments );
restore_current_blog(); // Restore to current site
wp_mail( $to2, $subject2, $message, $headers2, $attachments );}
add_action( ‘save_post’, ‘conditional_multisite_wp_mail’, 10, 3 );Thanks in advance!
- On
- The topic ‘Multisite + wp_mail + conditional email templates’ is closed to new replies.