Created
February 14, 2019 17:00
-
-
Save jentheo/d8b365504baef5d9a1cc0dc20f800c36 to your computer and use it in GitHub Desktop.
CC organizers on registrations
This file contains hidden or 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 | |
| /** | |
| * BCC event organizers email on all Event Tickets' RSVP and commerce ticket emails so they get a copy of it too | |
| */ | |
| function bcc_all_event_organizers( $headers, $event_id, $order_id ) { | |
| //check if has organizer | |
| if ( ! tribe_has_organizer( $event_id ) ) { | |
| return $headers; | |
| } | |
| //get all organizers asociated to the event | |
| $event_organizers_ids = tribe_get_organizer_ids( $event_id ); | |
| //get all the event organizers emails for the event | |
| $event_organizers_emails = array(); | |
| foreach ( $event_organizers_ids as $organizer_id ) { | |
| $organizer_email = tribe_get_organizer_email( $organizer_id, false ); | |
| //make sure it's a valid email | |
| if ( is_email( $organizer_email ) ) { | |
| $event_organizers_emails[] = $organizer_email; | |
| } | |
| } | |
| if ( empty( $event_organizers_emails ) ) { | |
| return $headers; | |
| } | |
| $to = implode( ", ", $event_organizers_emails ); | |
| $headers[] = sprintf( 'Bcc: %s', $to ); | |
| return $headers; | |
| } | |
| add_filter( 'tribe_rsvp_email_headers', 'bcc_all_event_organizers', 20, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment