0

I have three extra roles and I would like to use the Toolbar to use the menu for the Editor role, but the Admin Menu for the roles Adminstrator & SuperAdmin. The one problem I run into is that the higher level roles will inherit the permission to also display the Toolbar menu, which is redundant as the Admin Menu is already taking care of.

Thanks for your advice.

  • Can you just hide the normal toolbar using CSS for admins? It's not really going to be a performance issue since it only loads for the backend. – leexonline Mar 26 '14 at 17:55
  • Did not think about it that way, I would assume that this should be possible w/o a problem. But no way to stop the inheritance of permissions 'the drupal way'? – el_reverend Mar 26 '14 at 18:02
  • Probably almost certainly but I'm not sure off the top of my head :) – leexonline Mar 26 '14 at 18:06
1

I recommend you to disable Toolbar module and use Administration Menu Source with Administration menu and enable Admin Menu Toolbar which will give you the same look as Drupal Toolbar.

Administration Menu Source:

Use a different menu as the Administration Menu. Configurable per role.

Custom Solution:

Create a custom module add the following hook_page_alter function:

function mymodule_page_alter(&$page) {
  global $user;

  if(!in_array('editor', array_values(array_map('strtolower', $user->roles))) &&
     !empty($page['page_top']['toolbar'])) {
    $page['page_top']['toolbar']['#access'] = FALSE;
  }
}

The above code will check the role of current user and will hide toolbar if current user is not editor.

Note: make sure to replace editor to whatever editor role you named.

  • This would require to setup the menu items as defined per the role but does not take permissions into account. If I were to add an allowance to admin a new section to the Editor then I would have to remember that I also manually need to add the menu item to that new menu. This might just be the preferred way, but the new admin is rather new and mistakes are bound to happen. – el_reverend Mar 26 '14 at 18:08
  • @el_reverend I see your point. However I edited my answer and included a custom solution. – Aboodred1 Mar 26 '14 at 18:32
  • That was a good idea and provides a good solution to this problem. Just on a side note, how does this affect performance? – el_reverend Mar 28 '14 at 5:16
  • @el_reverend, I don't think it will effect your site performance because the above function is not running any additional sql query. – Aboodred1 Mar 28 '14 at 16:14
  • 1
    Thanks for the update @Aboodred1 and clarification. I figured hook_page_alter will take some time but seemingly negligible. – el_reverend Mar 28 '14 at 17:06
0

You can use instead the admin menu module along with the admin menu source module. That should be it.

What is does is, you can allow admin menu for different user roles to display different set of menus.

i.e.

  • Create different menus for different roles.
  • choose the menu for different roles using admin menu source.
  • disable toolbar completely.

Check this video, which shows, how this can be achieved https://www.youtube.com/watch?v=txEDvQTTNXc

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.