This module allows you to restrict access to menu items1 based on user roles. It depends on the Drupal core menu.module—just activate both modules and edit a menu item as usual. There will be a new fieldset that allows you to restrict access by role. The fieldset also appears in the node edit form.
1We wrote "menu items", not "nodes". This module does not prevent users from accessing the destination nodes. It only changes the visibility of the menu items.
Warning: Update in 6.x-1.x-dev (and next in 1.9)
The newest 6.x-1.x-dev reverts a change made in version 1.8 so administrators do not see hidden menus by default. However, the main administrator user (UID 1) still sees hidden menus unless you go to the new administrative screen and change the flags there.
Note also that the module was moved from the "Others" package to the "Menu" package. It seems to make sense to have it there since most menu related modules are found there.
- See https://www.drupal.org/node/2202293
- Maintainer wanted!
A Drupal 7 version is available although it doesn't work very well yet. The Drupal 7 users will appreciate if you can become a maintainer as Alexis is not working on Drupal 7 at all anymore.
Maintainer & Sponsor
Alexis Wilke is maintaining the D6 version.
The current sponsor is Made to Order Software Corp. Click to check out our other modules.
Where is this module used?
Cannot tell you which links are being hidden, but the module is now in use on the Linus Geek Page website. For this reason, I created an official version: 1.0.
I have used this module to allow a customer to edit a page (A) but not another (B). The end users see page B which includes node A in some way (i.e. InsertNode). So I wanted the end user to see the menu for B, but not the menu of A. However, my customer, once logged in, should see A because that's theirs to go and edit the content that appears on B.
Do I need this module?
[If you are using Drupal 5, ignore this and go to the Drupal 5 entry below!]
It is very likely that you do not need this module at all.
Log In, Log Out, Register & My Account
When you want to create a "Log In" menu item, in any menu, make it point to "user/login". That way it will disappear once a user is logged in. You probably know about the "Log Out" path, it is shown in the Navigation menu: "logout". To offer a Register menu item to anonymous users, make the link point to "user/register". And if you want to show a "My Account" link, use "user". That will always be visible and if an anonymous user tries that link, he will first be asked to log in.
- Log In, user/login
- Log Out, logout
- Register, user/register
- My Account, user
Consider the destination node access instead
You may want to use modules that control node access rights. In Drupal 6 a menu link that points to a node that cannot be accessed by the current user is not shown to that user. That's much simpler than having to edit each menu item for specific role permissions!
If you need finer control over node access rights, have a look at:
- content access (Read node 220680, comment 1084593)
So?! What is this module for???
Now... There are a few cases when hiding a menu item by role can still be useful. Although rare, it happens.
- You are dealing with external links (these are considered public and have full access rights by default.)
- Menus that you do not want to show to certain users although the destination pages are still freely accessible.
For example, you could have a site with a menu for registered users and a menu used to appeal to new users so they create an account:
- My Account
- Edit my info
- Send a message to my friends
- Log Out
- New to This Website?
- Check out why you should register
- Still not convince? Check our video!
- Register Now
- Already have an account? Log In now!
The "My Account" menu should probably not appear when your users are not yet logged in. Install menu_per_role, edit the "My Account" menu item, and select all the roles except "anonymous". Note that this case can also be solved by changing the access rights of the node pointed to by "My Account" menu item.
The "New to This Website" menu should definitively be removed once the person is logged in. Install menu_per_role, edit the "New to This Website" menu item, and mark it for the "anonymous" role. This way, the reasons why this site is worth the trouble are still accessible to the logged in users, just not directly accessible through the menu.
Note that if you add a role later that should have access to (most) of the menu items and you already have some roles selected, you will have to edit each menu item to fix them. (If you have a patch for a mass update, it is welcome! Post it in this issue.)
Up until Drupal 6.9, you had to apply a patch to fix the Drupal core menu module. If you have Drupal 6.10 or better, the patch is applied against the core already.
The patch is available inside the module. Extract the module first then check out the README.txt file for more information about this.
2011-02-04 (version 6.9) Changed the behavior for administrators. Now the main administrator (UID=1) sees everything but you can turn that off and the menu per role administrators (other than UID=1) don't see any of the hidden menus by default. Again, this can be changed so administrators can see the menu items. See the Administer » Site configuration » Menu per Role settings page.
Known Issues in D6 version
None (ha! ha!)
Why is this useful?
In D5, the menu module does NOT check the destination nodes to know whether the node is accessible to the current user. The result are clicks that send users to nodes that are not accessible (i.e. Resulting in numerous Access Denied errors if you have many protected nodes.)
This module will help you fix that problem by updating your menu items with the correct permissions.
Unfortunately the module requires a patch for Drupal's menu.inc. Be sure to read the README.txt.
There is currently no one maintaining the D5 version of this module. Feel free to contact us if you are interested in doing so.
By default, Drupal allows only users with "administrer menu permission" to add, modify or delete menu items. In case you want for instance to let certain users manage primary links or secondary links but not navigation menu, this module provides this functionality.
- Maintenance status: Seeking new maintainer
- Development status: Maintenance fixes only
- Module categories: Content Display
- Reported installs: 13,602 sites currently report using this module. View usage statistics.
- Downloads: 95,995
- Last modified: August 2, 2016
- Stable releases receive coverage from the Drupal Security Team.
Look for the shield icon below.