Support

Home Forums Event Espresso Premium Incorrect Date Format for Additional Registants

Incorrect Date Format for Additional Registants

Posted: September 19, 2024 at 9:47 am

Viewing 2 reply threads


pathwise

September 19, 2024 at 9:47 am

Hello 🙂

We use Event Espresso + WP Fusion + Groundhogg (CRM)

WP Fusion connects Event Espresso to Groundhogg, it passes the user’s data (name, ticket price, event start date) to their Groundhogg profile.

We are experiencing a problem where the Event Start Date field in Groundhogg is not populating for Additional Registrants. Works just fine for the Primary Registrant, though.

A developer did write this custom code and I am having a look at your developer docs to see if anything stands out that may be preventing the Start Date field from populating in Groundhogg:

/**
* Add Ticket Price Custom Field in WP Fusion to send Event Espresso Ticket Price to Groundhogg
* @param array $update_data
* @param EE_Registration $registration
* @return array
*/
function sync_extra_ee_fields_to_groundhogg( array $update_data, EE_Registration $registration ) {

$ticket_price = '';
$start_date = '';
$end_date = '';
$registration_date = '';
$instructors = '';

try {
// Get the ticket price.
$ticket_price = $registration->ticket()->price();

} catch ( EE_Error|ReflectionException $e ) {
write_log( '[ERROR] WP Fusion Custom Filter $ticket_price: ' . $e->getCode() . ' ' . $e->getMessage() );
}

try {
// Get the associated event
$event = $registration->event();

// Get the primary datetime object for the event
$datetime = $event->primary_datetime();

// Get the event start and end times using the EE_Datetime methods
$start_date = $datetime ? $datetime->start_date("Y-m-d H:i:s") : '';
$end_date = $datetime ? $datetime->end_date("Y-m-d H:i:s") : '';
} catch (EE_Error|ReflectionException $e) {
write_log('[ERROR] WP Fusion Custom Filter $start_end_dates: ' . $e->getCode() . ' ' . $e->getMessage());
}

try {
// Get registration date
$registration_date = $registration->pretty_date( "Y-m-d", "H:i:s" );

} catch ( EE_Error|ReflectionException $e ) {
write_log( '[ERROR] WP Fusion Custom Filter $registration_date: ' . $e->getCode() . ' ' . $e->getMessage() );
}

try {
// Make sure the people helper class is loaded.
EE_Registry::instance()->load_helper('People_View');

// Get the people objects assigned to event
$person_list = EEH_People_View::get_people_for_event( $event->ID() );

// Get the first and last name of each person
$instructor_list = array();
foreach( $person_list as $person_array ) {
foreach ( $person_array as $person ) {
if ($person instanceof EE_Person) {
$instructor_list[] = $person->fname() . ' ' . $person->lname();
}
}
}

// Concat the instructors comma separated
$instructors = implode( ', ', $instructor_list );

} catch (EE_Error|ReflectionException $e) {
write_log( '[ERROR] WP Fusion Custom Filter $instructors: ' . $e->getCode() . ' ' . $e->getMessage() );
}

// Add the ticket price to the GroundHogg customer data.
$update_data['ticket_price'] = $ticket_price;
$update_data['start_date'] = $start_date;
$update_data['end_date'] = $end_date;
$update_data['registration_date'] = $registration_date;
$update_data['instructors'] = $instructors;

// Return the updated customer data.
return $update_data;
}
add_filter( 'wpf_event_espresso_customer_data', 'sync_extra_ee_fields_to_groundhogg', 10, 2 );

WP Fusion support said the following: “Your start date is coming from Event Espresso with the time included twice: “09:00:00 9am”

This is an invalid date format, and so WP Fusion can’t convert it before syncing to Groundhogg.”

I will continue to dig but wanted to reach out here in case anything jumps out to you. Thanks! 😀 -Anna


pathwise

September 19, 2024 at 9:54 am

Is customer data processed differently for Additional Registrants?


Tony

  • Support Staff

September 19, 2024 at 4:23 pm

Hi there,

A developer did write this custom code and I am having a look at your developer docs to see if anything stands out that may be preventing the Start Date field from populating in Groundhogg:

Does the same thing happen if you test a registration without this custom code being active?

This part doesn’t make sense to me:

WP Fusion support said the following: “Your start date is coming from Event Espresso with the time included twice: “09:00:00 9am”

This is an invalid date format, and so WP Fusion can’t convert it before syncing to Groundhogg.”

Is that separate from the code above? It doesn’t make sense in the current context as the datetime formats are passed to the methods used, for example:

$datetime->start_date("Y-m-d H:i:s")

Is going to give you the start date in that format regardless of the value.

Is customer data processed differently for Additional Registrants?

In what way? They are looped over and processed in the same way but they are treated as additional registrants… but that does NOT mean they would have a different datetime value.

—-

So to clarify here, is the issue here from the custom code above or WPFusion processing?

You’re asking if we process the data differently, but it’s not EE that’s processing this, it’s WPFusion and your custom code from what I can tell?

Viewing 2 reply threads

You must be logged in to reply to this support post. Sign In or Register for an Account

Event Espresso