Programmatically change the user's password

  • Method 1: Pure Drupal API
$user = \Drupal\user\Entity\User::load($uid);
$user->setPassword('newpassword');
$user->save();
$ drush upwd 1 --password="newpassword"
$ drupal user:password:reset

 

********************************** ************************* ************************ **************** ****************** *********** ************** ************* ************ *************