Created
May 17, 2020 17:20
-
-
Save tobeyadr/b2a773a6187038492ff79c87feceaabc to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Add CC spouse email address | |
*/ | |
add_filter( 'groundhogg/email/headers', function ( $headers = [] ){ | |
// The contact ID is not passed, so let's get it from the global | |
// Check if the event queue is running, if it's not then this is not relevant... | |
if ( ! \Groundhogg\Queue\Event_Queue::is_processing() ){ | |
return $headers; | |
} | |
$contact = \Groundhogg\Plugin::$instance->event_queue->get_current_contact(); | |
// Make sure the contact is real | |
if ( ! $contact || ! $contact->exists() ){ | |
return $headers; | |
} | |
$spouse_email = $contact->get_meta( 'spouse_email' ); | |
// If the email address is valid add the CC header | |
if ( is_email( $spouse_email ) ){ | |
$headers[ 'cc' ] = $spouse_email; | |
} | |
return $headers; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment