This function retrieves a user’s CRM contact ID based on their WordPress user ID.


wpf_get_contact_id( $user_id = false, $force_update = false )
  • $user_id (int) (Optional): The user ID to the contact of.
  • $force_update (bool) (Optional): If the contact ID should be automatically saved.


(mixed) Returns a string of the contact ID, or false if nothing is found.

#Get the current user’s contact ID

$contact_id = wpf_get_contact_id();

#Get the contact ID for a different user

$contact_id = wpf_get_contact_id( $user_id );

#Force an update of the user’s contact ID by sending an API call to your CRM

In this case the updated contact ID will automatically be saved to the local user meta after it’s been retrieved.

$contact_id = wpf_get_contact_id( $user_id, true );

Was this helpful?