Skip to content

Instantly share code, notes, and snippets.

@jessepearson
Created October 31, 2016 17:19
Show Gist options
  • Save jessepearson/fea13a281882b66d3a28d9b960312904 to your computer and use it in GitHub Desktop.
Save jessepearson/fea13a281882b66d3a28d9b960312904 to your computer and use it in GitHub Desktop.

Revisions

  1. jessepearson created this gist Oct 31, 2016.
    29 changes: 29 additions & 0 deletions add_bcc_to_certain_emails.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    <?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(
    '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 <[email protected]>' ."\r\n",
    );
    }

    return $headers;
    }
    add_filter( 'woocommerce_email_headers', 'add_bcc_to_certain_emails', 10, 2 );