function demo_umami_set_users_passwords

Same name and namespace in other branches
  1. 9 core/profiles/demo_umami/demo_umami.profile \demo_umami_set_users_passwords()
  2. 8.9.x core/profiles/demo_umami/demo_umami.profile \demo_umami_set_users_passwords()
  3. 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 57

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();
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.