Need a bit of help with custom code please

I had been given a custom snippet to add multiple admin email addresses for Membership 2 emails.
But is there any way that can be modified to BCC those additional admins instead, so their email addresses don't appear in any headers the users might see?

  • Pawel
    • Staff

    Hello,

    Let me change the snippet you've received to suit your needs. The code will change slightly to look like this:

    add_filter( 'ms_model_communication_send_message_headers', function( $headers ){
    
        $additional_emails = array(
            'admin1@test.com',
            'admin2@test.com',
            'admin3@test.com',
            'admin4@test.com'
        );
    
        $headers = "Bcc: " . implode( ", ", $additional_emails ) . "\r\n" . $headers;
    
        return $headers;
    } );

    The instructions to use it are still the same. Just substitute the old snippet code for this one.

    Please test and confirm if it worked okay.

    cheers,
    Pawel

  • Pawel
    • Staff

    Hello,

    Okay, so if I'm understanding it well, the HTML tags are displayed in the body of the message? Please try this updated snippet:

    add_filter( 'ms_model_communication_send_message_headers', function( $headers ){
    
        $additional_emails = array(
            'admin1@test.com',
            'admin2@test.com',
            'admin3@test.com',
            'admin4@test.com'
        );
    
    	foreach($additional_emails as $email) {
        	$headers[] = "Bcc: " . $email . "\r\n";
    	}
    
        return $headers;
    } );

    This should work. If not, I can log in and to your site and run some tests to see what is causing this code to break.

    best regards,
    Pawel

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.