function drush_user_password

8.0.x user.drush.inc drush_user_password($inputs)
6.x user.drush.inc drush_user_password($name)
7.x user.drush.inc drush_user_password($inputs)
4.x user.drush.inc drush_user_password($name)
5.x user.drush.inc drush_user_password($name)
master user.drush.inc drush_user_password($inputs)

Sets the password for the account with the given username

1 string reference to 'drush_user_password'
user_drush_command in commands/user/user.drush.inc
Implementation of hook_drush_command().

File

commands/user/user.drush.inc, line 343
Drush User Management commands

Code

function drush_user_password($name) {
  $pass = drush_get_option('password');
  if (empty($pass)) {
    return drush_set_error("You must specify a password!");
  }
  if (drush_drupal_major_version() >= 7) {
    $user = user_load_by_name($name);
  }
  else {
    $user = user_load(array('name' => $name));
  }
  if ($user !== FALSE) {
    if (!drush_get_context('DRUSH_SIMULATE')) {
      $user_object = user_save($user, array('pass' => $pass));
      if ($user_object === FALSE) {
        drush_set_error("Could not change the password for the user account with the name " . $name . "!");
      }
    }
  }
  else {
    drush_set_error("The user account with the name " . $name . " could not be loaded!");
  }
}