Skip to content
Snippets Groups Projects
Commit b97f821b authored by Eric Bremner's avatar Eric Bremner
Browse files

ISTWCMS-4025: removing manage link in admin toolbar for strictly authenitcated users only

parent f486d8e1
No related branches found
No related tags found
No related merge requests found
......@@ -135,3 +135,30 @@ function uw_cfg_common_form_webform_settings_submissions_form_alter(array &$form
unset($form['submission_behaviors']['token_update']);
unset($form['views_settings']);
}
/**
* Implements hook_toolbar_alter().
*
* 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();
// 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']);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment