Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created July 12, 2019 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/3457c021e95182fed3de311a5f59d894 to your computer and use it in GitHub Desktop.
Save joshfeck/3457c021e95182fed3de311a5f59d894 to your computer and use it in GitHub Desktop.
Event Espresso 4, Infusionsoft. Add a custom field value for "Primary Attendee" to guest contact records.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function ee_is_track_attendee_back_to_purchaser( $is_contact_data, $ee_attendee ) {
if( $ee_attendee instanceof EE_Attendee ) {
$checkout = EE_Registry::instance()->SSN->checkout();
if ( $checkout instanceof EE_Checkout ) {
$transaction = $checkout->transaction;
if ( $transaction instanceof EE_Transaction ) {
$primary_reg = $transaction->primary_registration();
if ($primary_reg instanceof EE_Registration) {
$attendee = $primary_reg->attendee();
if ($attendee instanceof EE_Attendee) {
if ($attendee->id() != $ee_attendee->id()) {
$is_contact_data[ '_PrimaryContact' ] = $primary_reg->attendee()->full_name();
}
}
}
}
}
} else {
EE_Error::add_error(sprintf(
__(
'ee_is_track_attendee_back_to_purchaser was not called with an EE_Attendee but a %s',
'event_espresso'
), gettype( $ee_attendee )), __FILE__, __FUNCTION__, __LINE__ );
}
return $is_contact_data;
}
add_filter(
'FHEE__EED_Infusionsoft__save_infusionsoft_attendee__extra_attendee_data',
'ee_is_track_attendee_back_to_purchaser',
10,
2
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment