5

I have a single menu item that I would like to show or hide based on user role.

Use case: I have a membership site with paid and free memberships. In the navigation menu, I want to show a link for users who do not have the "paid" role to the "Upgrade your account" page. There's no need to limit access; I simply want to show or hide the link.

I know I could make a separate menu and restrict access to that menu block by role, but is there an easy way to do the same for a single menu item link in an existing menu?

1

There is a way to do it without an extra module if the "Upgrade your Account" page is a view. Then you can limit access for that view to anonymous users and add the menu entry in that view.

  • I use Panels, so I will add it in Panels. I much prefer this approach to installing an unstable module just for one link. – Patrick Kenny Apr 28 '12 at 6:53
  • yeah, I usually take the same approach, "keep it simple" is a great mantra – uwe Apr 28 '12 at 14:55
4

You may try Menu per Role

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.

enter image description here

D7 release is not stable yet its 7.x-1.x-dev

  • D7 is indeed dev, but it worked for me perfectly. – Druvision May 24 '13 at 8:49
1

Another module solution to this that I recently found is Menu Item Visibility. While it is still in beta, it actually works in D7 right now, which I couldn't get Menu Item per Role to do. (I had to keep clearing the cache every time a user saved their profile to rebuild the menu.)

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.