Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created September 25, 2017 14:59
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/07d2c6598f33043b67e5b9f4f8645f3b to your computer and use it in GitHub Desktop.
Save joshfeck/07d2c6598f33043b67e5b9f4f8645f3b to your computer and use it in GitHub Desktop.
Infusionsoft custom field example. Event Espresso 4.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function ee_infusionsoft_save_my_custom_questions( $is_contact_data, $ee_attendee ) {
if( $ee_attendee instanceof EE_Attendee ) {
//get the last answer this attendee provided to the question with admin label 'custom_question'
$custom_question_answer = EEM_Answer::instance()->get_one(
array(
array(
'Registration.ATT_ID' => $ee_attendee->ID(),
// change custom_question on the next line to match the admin label in EE > Registration Forms > Questions
'Question.QST_admin_label' => 'custom_question'
),
'order' => 'DESC'
)
);
if( $custom_question_answer ){
// change _CustomQuestion on the next line to match the Infusionsoft custom field
$is_contact_data[ '_CustomQuestion' ] = $custom_question_answer->pretty_value();
}
}else{
EE_Error::add_error(
sprintf(
__(
'ee_infusionsoft_save_my_custom_questions 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_infusionsoft_save_my_custom_questions',
10,
2
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment