wpf_event_espresso_customer_data

#Overview

This filter is run during an Event Espresso registration, after WP Fusion has extracted the customer data from the registration object. It can be used to sync additional data from an Event Espresso registration to custom fields in your CRM.

To use the code examples below, add them to your active theme’s functions.php file.

#Parameters

  • $order_data: This is an array of key value pairs representing WordPress meta fields and their corresponding values.
  • $registration: The Event Espresso registration object

#Examples

#Override attendee emails

This example overrides the email addresses of attendees to include the event name that the attendee registered for.

The email address synced to the CRM will then be formatted like email+{event_name}@domain.com

function alt_emails_for_attendees( $update_data, $registration ) {

	$email_parts = explode( '@', $update_data['user_email'] );

	// Convert [email protected] to [email protected]:
	$update_data['user_email'] = $email_parts[0] . '+' . strtolower( $update_data['first_name'] ) . '@' . $email_parts[1];

	// Or, __alternate method__: Convert [email protected] to [email protected]:
	$event      = $registration->event();
	$event_name = sanitize_title( $event->name() );
	$event_name = str_replace( '-', '_', $event_name );

	$update_data['user_email'] = $email_parts[0] . '+' . $event_name . '@' . $email_parts[1];

	return $update_data;

}

add_filter( 'wpf_event_espresso_customer_data', 'alt_emails_for_attendees', 10, 2 );

#Sync event meta

This example grabs two postmeta keys (custom_field_one and custom_field_two) off the Event Espresso event and merges them into the data synced to the CRM for the attendee. This can be used to sync additional event properties to the attendee’s contact record in the CRM.

To enable the custom fields for sync they must first be enabled for sync and mapped to custom fields in your CRM via the Contact Fields settings.

function sync_event_custom_fields( $update_data, $registration ) {

	$event_id = $registration->event_ID();

	$update_data['custom_field_one'] = get_post_meta( $event_id, 'custom_field_one', true );
	$update_data['custom_field_two'] = get_post_meta( $event_id, 'custom_field_two', true );

	return $update_data;

}

add_filter( 'wpf_event_espresso_customer_data', 'sync_event_custom_fields', 10, 2 );

Was this helpful?