Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Last active October 17, 2018 19:56
Show Gist options
  • Save cliffordp/c4fb2ea8fb5ca44973ff06e6facc9742 to your computer and use it in GitHub Desktop.
Save cliffordp/c4fb2ea8fb5ca44973ff06e6facc9742 to your computer and use it in GitHub Desktop.
BCC multiple email addresses, including the site admin email address, on all Event Tickets' RSVP ticket emails so they get a copy of it too
<?php
/**
* BCC multiple email addresses, including the site admin email address, on all Event Tickets' RSVP ticket emails so they get a copy of it too
*
* Updated 2018-01-18 for Event Tickets 4.5.2+
* HOWEVER, this has been tested and we think there might be an issue with
* the version of PHPMailer (what wp_mail() uses) included with WordPress, which
* is why BCCs are not working.
* Therefore, you can use this other snippet for how to initiate a new, separate
* email message to the Organizer (but it could be customized to go to someone
* else, such as the site admin):
* @link https://gist.github.com/niconerd/16770b84adb6156aaa77948bf208bacb
*
* From https://gist.github.com/cliffordp/c4fb2ea8fb5ca44973ff06e6facc9742
* A fork of https://gist.github.com/cliffordp/4f06f95dbff364242cf54a3b5271b182
* For https://theeventscalendar.com/support/forums/topic/event-tickets-free-not-plus-rsvp-notifications/#post-1272819
*
* @link https://developer.wordpress.org/reference/functions/wp_mail/#comment-349
*/
function cliff_et_rsvp_bcc_admin_and_more_ticket( $email_headers, $event_id, $order_id ) {
// did not work? $event_organizer_emails = tribe_get_organizer_email( $event_id );
$bccs = array(
get_option( 'admin_email' ),
// the site admin email, probably do not want to edit this line
'[email protected]',
// edit or delete this line
'[email protected]',
// edit or delete this line, and even add another if you want
);
if ( is_array( $email_headers )) { // should always be true but just to be safe
// add each BCC email if it's a valid email address
foreach ( $bccs as $bcc ) {
$bcc = sanitize_email( $bcc );
if ( is_email( $bcc ) ) {
$email_headers[] = sprintf( 'Bcc: %s', $bcc );
}
}
}
return $email_headers;
}
add_filter( 'tribe_rsvp_email_headers', 'cliff_et_rsvp_bcc_admin_and_more_ticket', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment