/** * Implements hook_shortcut_default_set(). */ function {{ machine_name }}_shortcut_default_set($account) { // Use a special set of default shortcuts for administrators only. $roles = \Drupal::entityTypeManager()->getStorage('user_role')->loadByProperties(['is_admin' => TRUE]); $user_admin_roles = array_intersect(array_keys($roles), $account->getRoles()); if ($user_admin_roles) { return 'admin-shortcuts'; } }