Thursday, July 7, 2011

How will you get the user custom profile values?

To get custom profile values in code:

global $user;
$profile = profile_load_profile($user);
$custom1 = $user->profile_custom1

To save an array of form data back into the profile:

profile_save_profile($record, $user, $category, $register = FALSE);

Parameters

$edit: An array of profile field names as keys and the new values to save as the values (example: $edit['profile_first_name'] = 'John').
$user: An object, minimally just an object with the user id (example: $user->uid=1).
$category a string defining the profile category like 'Personal information'.
$register: Boolean, if this is a new user or not.

No comments:

Post a Comment