wpf_user_update

#Overview

This filter allows you to modify user meta data before it’s sent to your CRM. To use the code examples below, add them to your active theme’s functions.php file.

#Parameters

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

#Examples

#Save the full URL to a user’s profile photo

If you’re using Ultimate Member to run your site’s membership platform, and want to save a link to the user’s profile photo in your CRM, you’ll find that just syncing the profile_photo field gives you the name of the file, but not the full URL. Using wpf_user_update, we can modify this so the full URL to the user’s profile is sent.

function set_profile_photo_url( $user_meta, $user_id ) {
	
	// Changes "profile_photo.png" to "http://mysite.com/wp-content/uploads/ultimatemember/1/profile_photo.png"
	if( isset( $user_meta['profile_photo'] ) ) {
		$user_meta['profile_photo'] = content_url() . '/uploads/ultimatemember/' . $user_id . '/' . $user_meta['profile_photo'];
	}

	return $user_meta;


}

add_filter( 'wpf_user_update', 'set_profile_photo_url', 10, 2 );

#Sync a role title instead of role slug

This example converts the role slug volunteer_both to “Volunteer” when the role field is being synced to the CRM, either during a profile update or new user registration (via the wpf_user_register filter).

function volunteer_role( $user_meta, $user_id ) {

	if ( isset( $user_meta['role'] ) && 'volunteer_both' === $user_meta['role'] ) {
		$user_meta['role'] = 'Volunteer';
	}

	return $user_meta;

}

add_filter( 'wpf_user_register', 'volunteer_role', 10, 2 );
add_filter( 'wpf_user_update', 'volunteer_role', 10, 2 );