You are here

function demo_umami_set_users_passwords in Drupal 9

Same name and namespace in other branches
  1. 8 core/profiles/demo_umami/demo_umami.profile \demo_umami_set_users_passwords()
  2. 10 core/profiles/demo_umami/demo_umami.profile \demo_umami_set_users_passwords()

Sets the password of admin to be the password for all users.

1 call to demo_umami_set_users_passwords()
demo_umami_form_install_configure_submit in core/profiles/demo_umami/demo_umami.profile
Submission handler to sync the contact.form.feedback recipient.

File

core/profiles/demo_umami/demo_umami.profile, line 35
Enables modules and site configuration for a demo_umami site installation.

Code

function demo_umami_set_users_passwords($admin_password) {

  // Collect the IDs of all users with roles editor or author.
  $ids = \Drupal::entityQuery('user')
    ->accessCheck(FALSE)
    ->condition('roles', [
    'author',
    'editor',
  ], 'IN')
    ->execute();
  $users = \Drupal::entityTypeManager()
    ->getStorage('user')
    ->loadMultiple($ids);
  foreach ($users as $user) {
    $user
      ->setPassword($admin_password);
    $user
      ->save();
  }
}