wpf_get_user_meta

#Overview

During a user registration or when running a Push User Meta batch operation, WP Fusion gets all of the available metadata for a user out of the wp_usermeta database table, using get_user_meta( $user_id );, and then any enabled fields are synced on to your CRM.

This filter allows you to modify the array of metadata that’s gathered for each user.

It’s most commonly used to include user data found in different database tables, for example data added by a membership plugin.

#Parameters

  • $user_meta: Array of user meta data gathered from the database, in the format array( 'meta_field' => 'value' ).
  • $user_id: ID for the user being updated.

#Examples

#Get an XProfile field value out of the BuddyPress XProfile tables

WP Fusion already includes this code in the BuddyPress / BuddyBoss integration, but we’ll use it here as an example for how wpf_get_user_meta works.

function my_wpf_xprofile_data( $user_meta, $user_id ) {
	
	$xprofile_data = BP_XProfile_ProfileData::get_all_for_user( $user_id );

	if ( isset( $xprofile_data['Birthday'] ) ) {
		$user_meta['birthday'] = $xprofile_data['Birthday']['field_data'];
	}

	return $user_meta;

}

add_filter( 'wpf_get_user_meta', 'my_wpf_xprofile_data', 10, 2 );

In this example before the data is sent to the CRM, the value for the “Birthday” field is extracted from the XProfile database tables and merged into the array.

Was this helpful?