function DemoUmamiHooks::setUserPasswords
Sets the password of admin to be the password for all users.
1 call to DemoUmamiHooks::setUserPasswords()
- DemoUmamiHooks::installConfigureSubmit in core/
profiles/ demo_umami/ src/ Hook/ DemoUmamiHooks.php - Submission handler to sync the contact.form.feedback recipient.
File
-
core/
profiles/ demo_umami/ src/ Hook/ DemoUmamiHooks.php, line 132
Class
- DemoUmamiHooks
- Hook implementations for demo_umami.
Namespace
Drupal\demo_umami\HookCode
public function setUserPasswords($admin_password) : void {
$user_storage = $this->entityTypeManager
->getStorage('user');
// Collect the IDs of all users with roles editor or author.
$ids = $user_storage->getQuery()
->accessCheck(FALSE)
->condition('roles', [
'author',
'editor',
], 'IN')
->execute();
$users = $user_storage->loadMultiple($ids);
foreach ($users as $user) {
$user->setPassword($admin_password);
$user->save();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.