• Resolved dornstudio

    (@dornstudio)


    Hi there,

    I’m using your plugin in a multisite environment.

    My use case:

    1. On save_post
    2. I want to send an email to “User A” via “Site 1”
    3. I want to send an email to “User B” via “Site 2”
    4. 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!

Viewing 1 replies (of 1 total)
  • Thread Starter dornstudio

    (@dornstudio)

    I made a stupid error in my code and had my ‘manual’ site ID set to the current site ID. Your plugin works brilliantly.

Viewing 1 replies (of 1 total)
  • The topic ‘Multisite + wp_mail + conditional email templates’ is closed to new replies.