Skip to content

Instantly share code, notes, and snippets.

@lukecav
Forked from jessepearson/add_bcc_to_certain_emails.php
Last active September 29, 2017 14:31
Show Gist options
  • Select an option

  • Save lukecav/cd6b7c8b9fdf4d3baf7662050bb607ea to your computer and use it in GitHub Desktop.

Select an option

Save lukecav/cd6b7c8b9fdf4d3baf7662050bb607ea to your computer and use it in GitHub Desktop.
Add a BCC to certain defined emails sent from WooCommerce
/**
* 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(
'customer_renewal_invoice', // Renewal invoice from WooCommerce Subscriptions
'customer_processing_order', // Customer Processing order from WooCommerce
);
// if our email object is in our array
if ( in_array( $object, $add_bcc_to ) ) {
// change our headers
$headers = array(
$headers,
'Bcc: Me <me@example.com>' ."\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