Skip to main content
added 89 characters in body
Source Link

UPDATED:

If you are going to create new users using user_save() then follow the following syntax.

$user = array(
   'name' => $userdata['name'],
   'mail' => $userdata['mail'],
   'init' => $userdata['mail'],
   'pass' => user_password(8),
);

Now call the function user_save() and pass the user info as second arg.

$account = user_save(null, $user);
if($account){
     _user_mail_notify('register_admin_created', $account);
}

To update values for already saved user.

$account = user_load(array('uid' => $userdata['uid']));
$updates = array(
    'pass' => user_password(),
    'name' => 'new_name',
    'roles' => array(
        <rid> => '<role title>';
    ),
);

user_save($account, $updates);

If you are going to create new users using user_save() then follow the following syntax.

$user = array(
   'name' => $userdata['name'],
   'mail' => $userdata['mail'],
   'init' => $userdata['mail'],
   'pass' => user_password(8),
);

Now call the function user_save() and pass the user info as second arg.

$account = user_save(null, $user);
if($account){
     _user_mail_notify('register_admin_created', $account);
}

To update values for already saved user.

$account = user_load(array('uid' => $userdata['uid']));
$updates = array(
    'pass' => user_password(),
    'name' => 'new_name',
);

user_save($account, $updates);

UPDATED:

If you are going to create new users using user_save() then follow the following syntax.

$user = array(
   'name' => $userdata['name'],
   'mail' => $userdata['mail'],
   'init' => $userdata['mail'],
   'pass' => user_password(8),
);

Now call the function user_save() and pass the user info as second arg.

$account = user_save(null, $user);
if($account){
     _user_mail_notify('register_admin_created', $account);
}

To update values for already saved user.

$account = user_load(array('uid' => $userdata['uid']));
$updates = array(
    'pass' => user_password(),
    'name' => 'new_name',
    'roles' => array(
        <rid> => '<role title>';
    ),
);

user_save($account, $updates);
Source Link

If you are going to create new users using user_save() then follow the following syntax.

$user = array(
   'name' => $userdata['name'],
   'mail' => $userdata['mail'],
   'init' => $userdata['mail'],
   'pass' => user_password(8),
);

Now call the function user_save() and pass the user info as second arg.

$account = user_save(null, $user);
if($account){
     _user_mail_notify('register_admin_created', $account);
}

To update values for already saved user.

$account = user_load(array('uid' => $userdata['uid']));
$updates = array(
    'pass' => user_password(),
    'name' => 'new_name',
);

user_save($account, $updates);