Tuesday, 20 October 2015

Drupal update the user email and name using user id UID

This is a small function used to update the user email
@param $uid Is the user id of the particular user
@param $email New email address to change to the particular user UID
function UpdateUserEmail($uid, $email){
  // load user object
$existingUser = user_load($uid);

// create an array of properties to update you can add what ever user property you want to edit in this array.
$edit = array(
  'name' => $email,
  'mail' => $email,
  'init' => $email,

// save existing user
    (object) array('uid' => $existingUser->uid),
// load user object

Refference links


No comments:

Post a Comment