Show only the relevant admin menu items to your content manager
Ever wanted to show your customers only the menu items in the Admin menu you want them to see? That is possible.
Drupal has a magnificent access control system, where you can cleanly build a sophisticated user access management system. But Drupal out of the box has some 'thoughts' of it's own concerning configuring of some access restrictions. Some of the access restrictons are bundled. So if you give access to a certain admin-area, it is possible you also provide 'bundled' access to another area.
For example: The 'Administer menu' permission, provides access to add/edit menu items. But also grants access to administer the menu. The first one is perfect for content managers, the second one: you don't want your content manager to add/edit/delete a complete menu!
We here at Lucius HQ always customize this per role, so the admin menu becomes more usabilicious. Your customer get's more statisfied and your company get's less helpdesk-calls :-)
How to set it up
- We create an extra permission with hook_perm(), so website administrator can configure what role can have your custom access
- We use hook_menu_alter() (since Drupal 6 in API) to check user's permission and if needed: change the default access
The Allmighty code
/** * Implementation of hook_perm(). * */ function YOURMODULE_perm() { } /** * Implementation of hook_menu_alter(). * In this example: restrict access to * + site settings section * + node settings * */ function YOURMODULE_menu_alter(&$items) { $items['admin/settings']['access callback'] = '_YOURMODULE_checkperm'; $items['admin/content/node-settings']['access callback'] = '_YOURMODULE_checkperm'; } /** * Private function to check if logged in user has correct perms to access the menu item * */ function _YOURMODULE_checkperm(){ return user_access('Allow access to administration items'); }
Extensively test your code
Since we are working with access control it is very important to test your scripts thoroughly. So be very careful with building custom scripts like this, if you don't know exactly what you are doing.
Feedback, Questions about access restriction?
Or maybe you know a nice module that does the trick...
Please hit me on Twitter for all your feedback, and any other issue!
Over Joris Snoek

Joris Snoek is Full time Drupal verslaafd, Project leider bij Lucius & Technology-freak. Tevens afgestudeerd in bedrijfskundige informatica en houdt veel van: muziek productie, snowboarden, tennis & fitness. En: heeft een zwak voor Duitse herders.
Over Peter Terpstra

Peter Terpstra is accountmanager bij Lucius.
Relatiebeheer en trajectbegeleiding van begin tot eind vallen onder zijn hoede.
Laatste tweet van Joris
joris_lucius: Looking into #mongodb #drupal implementation. Looks promising so far. #performance http://drupal.org/project/mongodb
Volg alle tweets van Joris