diff --git a/uw_cfg_common.module b/uw_cfg_common.module index 3695fbdbcd7cb21b60a73c2fad19231415446ca9..a9b2abf1929d75094dfbb4a25067811b4478c7d7 100644 --- a/uw_cfg_common.module +++ b/uw_cfg_common.module @@ -174,25 +174,24 @@ function uw_cfg_common_webform_create(WebformInterface $webform) { * Remove the Manage link from the toolbar for authenticated users. */ function uw_cfg_common_toolbar_alter(&$items) { - // Get the current user. $current_user = \Drupal::currentUser(); - // Ensure that the current user is not user1. - if ($current_user->id() !== '1') { - - // Get the roles of the user. - $roles = $current_user->getRoles(); + // No changes for user 1. + if ((int) $current_user->id() === 1) { + return; + } - // If there is only 1 role and that first role is authenticated, remove the - // manage link. If there are multiple roles then we know that they will have - // the Manage link, we are only removing the manage link for strictly - // authenticated users only. - if (count($roles) == 1 && $roles[0] == 'authenticated') { + // Get the roles of the user. + $roles = $current_user->getRoles(); - // Remove the manage link. - unset($items['administration']); - } + // If there is only 1 role and that first role is authenticated, remove the + // manage link. If there are multiple roles then we know that they will have + // the Manage link, we are only removing the manage link for strictly + // authenticated users only. + if (count($roles) == 1 && $roles[0] == 'authenticated') { + // Remove the manage link. + unset($items['administration']); } }