wpf_event_tickets_attendee_data

#Overview

This filter is run during an Event Tickets registration, after WP Fusion has collected the event and attendee data. It can be used to sync additional data from an Event Tickets registration to custom fields in your CRM.

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

#Parameters

  • $update_data: (array) This is an array of key value pairs representing WordPress meta fields and their corresponding values.
  • $attendee_id: (int) The Event Tickets attendee ID
  • $event_id: (int) The Event Tickets event ID
  • $ticket_id: (int) The Event Tickets ticket ID

#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, $attendee_id, $event_id, $ticket_id ) {

	$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_name                = sanitize_title( $update_data['event_name'];
	$update_data['user_email'] = $email_parts[0] . '+' . $event_name . '@' . $email_parts[1];

	return $update_data;

}

add_filter( 'wpf_event_tickets_attendee_data', 'alt_emails_for_attendees', 10, 4 );

#Sync custom event fields

This example registers a custom field for sync in the Contact Fields settings, and then populates that field value based on a postmeta entry attached to the event ID, with field key custom_field_key.

For more information on syncing data beyond the standard usermeta fields, see Detecting and Syncing Additional Fields.

// Add the field as available for sync on the Contact Field tab in the WPF settings

function wpf_event_meta_fields( $fields ) {

	$fields['custom_field'] = array(
		'label'  => 'Event Custom Field',
		'type'   => 'string',
		'group'  => 'tribe_events_event',
		'pseudo' => true,
	);

	return $fields;

}

add_filter( 'wpf_meta_fields', 'wpf_event_meta_fields' );

// Merge the custom field data into the attendee data sent to the CRM.
function sync_custom_event_field( $update_data, $attendee_id, $event_id, $ticket_id ) {

	$update_data['custom_field'] = get_post_meta( $event_id, 'custom_field_key', true );

	return $update_data;

}

add_filter( 'wpf_event_tickets_attendee_data', 'sync_custom_event_field', 10, 4 );

Was this helpful?