-
-
Save Yame-/00cfa388295e83a4150154deb611dd96 to your computer and use it in GitHub Desktop.
Add a BCC to certain defined emails sent from WooCommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // only copy this line if needed | |
/** | |
* Function adds a BCC header to emails that match our array | |
* | |
* @param string $headers The default headers being used | |
* @param string $object The email type/object that is being processed | |
*/ | |
function add_bcc_to_certain_emails( $headers, $object ) { | |
// email types/objects to add bcc to | |
$add_bcc_to = array( | |
'dpd_service_tracking_email', // DPD Tracking E-mail | |
); | |
// if our email object is in our array | |
if ( in_array( $object, $add_bcc_to ) ) { | |
// change our headers | |
$headers = array( | |
$headers, | |
'Bcc: Me <[email protected]>' ."\r\n", | |
); | |
} | |
return $headers; | |
} | |
add_filter( 'woocommerce_email_headers', 'add_bcc_to_certain_emails', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment