Skip to content

Instantly share code, notes, and snippets.

@tobeyadr
Created May 17, 2020 17:20
Show Gist options
  • Save tobeyadr/b2a773a6187038492ff79c87feceaabc to your computer and use it in GitHub Desktop.
Save tobeyadr/b2a773a6187038492ff79c87feceaabc to your computer and use it in GitHub Desktop.
<?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