Created
July 10, 2023 12:25
-
-
Save juanfra/e7015d52d2fc6f7e11280e4029ca0d84 to your computer and use it in GitHub Desktop.
BCC event organizers for the RSVP email.
This file contains 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 | |
//* 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