Support

Home Forums Event Espresso Premium Infusionsoft – Bring in the event Name into a custom field

Infusionsoft – Bring in the event Name into a custom field

Posted: January 13, 2016 at 5:06 pm


Catherine Miale

January 13, 2016 at 5:06 pm

Can I bring the event name into a custom field in Infusionsoft? The custom field name is InstructorTrainingCityST

If code is involved – I want to verify exactly where to put the code. I have a custom snipit php file that worked for the first function. espresso_only_tag_approved_regs

But not working for the next function I added. This is what I have now. Not working for function espresso_infusionsoft_save_date_field($attendee_data) {

<?php
/*
Plugin Name: Site plugin for rippedcertification.com
Description: Site specific code for rippedcertification.com
*/
/* Begin Adding Functions Below This Line; Do not include an opening PHP tag as this sample code already includes one! */
/*
* This code snippet is for the EE4 Infusionsoft addon.
* Using this, contacts in Infusionsoft can only be tagged when their corresponding
* registration in Event Espresso is approved.
* Ie, Infusionsoft contacts created from Event Espresso registrations who didn’t finish
* registering won’t ever be tagged in Infusionsoft
*/
add_filter( ‘FHEE__EEE_Infusionsoft_Registration__sync_to_infusionsoft__infusionsoft_tags’, ‘espresso_only_tag_approved_regs’, 10, 2 );
function espresso_only_tag_approved_regs( $tags, $registration ) {
if(
$registration instanceof EE_Registration &&
! in_array(
$registration->status_ID(),
array(
EEM_Registration::status_id_approved
))) {
//reg isn’t approved, don’t tag it yet
$tags = array();
}
return $tags;
}
/**
* Filters the $is_contact_data before it’s sent to infusionsoft
* in order to add the last registration’s custom question answers
* @param array $is_contact_data
* @param EE_Attendee $ee_attendee
*/
function espresso_infusionsoft_save_date_field($attendee_data) {

$clean_attendee_data = array(

//Example of a custom contact data field

//NOTE: You must prepend custom field database names with an underscore when accessing them through the API

‘_InstructorTrainingDate’ => $attendee_data[‘start_date’],

);

return array_merge($attendee_data, $clean_attendee_data);

}

add_filter( ‘filter_hook_espresso_infusionsoft_extra_attendee_data’, ‘espresso_infusionsoft_save_date_field’, 10, 1 );


Josh

  • Support Staff

January 13, 2016 at 5:25 pm

Hi Terry,

This looks like the same issue in the other thread. Your second function is trying to hook to a filter that only exists in Event Espresso 3’s infusionsoft add-on. There’s an equivalent filter hook in Event Espresso 4 and it’s documented here.


Catherine Miale

January 13, 2016 at 5:43 pm

I guess a better question is: If I take the code you’re directing me to, which phrases do I replace with which name (Infusionsof Field or Event Espresso field)?


Josh

  • Support Staff

January 13, 2016 at 5:57 pm

Both, and if you’re not sure how to get the correct field name for a value from Event Espresso, you can add some debugging to your code to find what values are in the $attendee_data object.

A very useful tool for this sort of thing is the kint debugger plugin (free to download on wordpress.org). Once installed, you can add something like this to your code:

d($attendee_data);

Then it will output the fields, values, and helper methods that are available to use.


Catherine Miale

January 13, 2016 at 6:23 pm

What word in the code do I replace with _InstructorTrainingCitySt (my Infusionsoft field name) and what word do I replace with the EE field name?


Josh

  • Support Staff

January 14, 2016 at 9:00 am

Hi there,

We tried to add the code to your site using the credentials you sent along with the support token form, but it turns out the credentials were invalid.

The code is prepared and posted in this gist:

https://gist.github.com/joshfeck/3fb137494e100abc925c

Can you copy the code into your site plugin?


Josh

  • Support Staff

January 14, 2016 at 9:24 am

Further to the above, it appears that the Infusionsoft API doesn’t accept an incoming custom field if it’s a date type field. I tried formatting the date exactly the same way as the date type field and it didn’t work. What you can do though is make a text field in Infusionsoft and the API will accept it.

The support post ‘Infusionsoft – Bring in the event Name into a custom field’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso