Skip to main content
2 of 2
improved formatting and grammar
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

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.

mchar
  • 1.7k
  • 1
  • 11
  • 20