By yan | Tue, 01/20/2015 - 16:00
The drupal admin menu module is something I use everyday. Recently, I ran into a problem with it.
I needed to give some users access to some specific menu items, however, no matter what I did, that particular user role could not see the menu items. It only displayed an empty admin menu at the top.
Even though the “access administration menu” and related drupal permissions were granted to the user role, and proper access, the admin menu module refused to display those menu items.
I got the impression that by reading the description “Display the administration menu at the top of each page.” I thought that would be enough. Nope.
After spending some time with the “trial and error approach”, I had finally narrowed down the permission that caused this problem. It’s the one called “Use the administration pages and help”.
After adding that permission to the role in question, the menu items were finally showing up.
For some reason, that permission controls whether the menu items get outputted or not. My curiosity started to grow so I began digging into it a little bit.
As it turns out, under the system.module on line 233, the administration pages and help is mapped to access administration pages. Then I ran another grep command and it turns out in the admin_menu.module line 77, the access argument is looking for “access administration pages”, which is the “Use the administration pages and help” permission.
Moreover, in the help file of admin menu (/admin/help/admin_menu), it provided the following explanation: “Second, a user must be a member of a role with the Access administration pages (system module) permission to view administrative links.” Therefore, It’s pretty clear that admin menu needs that permission.
In short, in order for the admin menu to display custom menu items. you need to give at least 2 permissions to that user role:
- Access administration menu
- Use the administration pages and help
The moral of the story is never assume anything and when in doubt, look into the code or read the documentation.