Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save juanfra/e7015d52d2fc6f7e11280e4029ca0d84 to your computer and use it in GitHub Desktop.
Save juanfra/e7015d52d2fc6f7e11280e4029ca0d84 to your computer and use it in GitHub Desktop.
BCC event organizers for the RSVP email.
<?php
//* Do NOT include the opening php tag
add_filter( 'tec_tickets_emails_dispatcher_rsvp_headers', 'my_add_bcc_email_organizers_headers', 10, 2 );
function my_add_bcc_email_organizers_headers( $headers, $dispatcher ) {
$email = $dispatcher->get_email();
$post_id = $email->get( 'post_id' );
if ( ! $post_id || ! function_exists( 'tribe_get_event' ) ) {
return $headers;
}
$event = tribe_get_event( $post_id );
if ( empty( $event ) ) {
return $headers;
}
// If the event has organizers set
if ( ! tribe_has_organizer( $post_id ) ) {
return $headers;
}
// Get the organizers
$organizers = tribe_get_organizer_ids( $post_id );
// Loop through the organizers
foreach ( $organizers as $organizer_id ) {
// Get the organizer email address
$organizer_email = stripslashes_deep( html_entity_decode( tribe_get_organizer_email( $organizer_id ), ENT_COMPAT, 'UTF-8' ) );
// Add the organizer email info to our emails array
$emails[] = $organizer_email;
}
if ( empty( $emails ) ) {
return $headers;
}
$headers['Bcc'] = implode( ",", $emails );
return $headers;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment