Menu per Role
This module allows you to restrict access to menu items1 per 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.
1 We wrote "menu items", not "nodes". This module does not prevent users from accessing the destination node. It only changes the visibility of the menu items.
Drupal 6
Maintainer
Alexis Wilke will be maintaining the D6 version.
Where is this module used?
Cannot tell you which links are being hidden, but the module is now in use on the Orangevale Chamber of Commerce website. For this reason, I created an official version: 1.0.
In this case, I have a problem with the InsertNode module that requires the destination node to be accessible by the users in order to show that node in another. So the destination nodes are not protectable. It is fine because they do not include top-secret content, but it is annoying to see the links if you are not part of the Chamber. Hence, the hiding of the links in the menus.
Do I need this module?
Short answer
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)
- node_privacy_byrole
- taxonomy_access
- forum_access
- image_gallery_access
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 by this menu.
Maintenance Consideration
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 the issue queue.)
Installation
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.
Updates
2008-12-28 Made a fix to the code I first checked. This one really gets calls as it is supposed to and it works.
Drupal 5
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.
Installation
Unfortunately the module requires a patch for Drupal's menu.inc. Be sure to read the README.txt.
Maintenance
There is currently no one maintaining the D5 version of this module. Feel free to contact us if you are interested in doing so.
