You can equally use either user_save()
or field_attach_update()
.
// Load the user's account.
global $user;
$account = user_load($user->uid);
$edit = $account->field_my_custom_field[LANGUAGE_NONE][0][value] = $new_value;
user_save($account, $edit);
// field_attach_update
$account->field_my_custom_field[LANGUAGE_NONE][0][value] = $new_value;
field_attach_update('user', $account);
The difference between using one function or the other is that user_save()
will update all the user fields whereas field_attach_update()
will update only the specified field.