How can I change my menu items depending on whether the user is logged in or not? For example, I would like my secondary navigation to have a "sign in" link if the user isn't authenticated and "log out" if the user is authenticated.

Thanks! Jane


Drupal's menu system checks the permissions of menu items that it connects to. So, depending on the permissions of your content you could use the same menu for users with different roles. Also if you use the path "user/login" in a menu and name it "Sign in" it will only show up when users are logged out. Similarly a menu item with "logout" as the path will only show up when a user is logged in.

| improve this answer | |
  • I totally agree more with this direction. AKAIK the only thing that cannot be achieved is a "My Account" link. This will end up being displayed for both anon and logged in users leading to some confusion. I know the question asker did not ask this part, however, it seems like it would be a reasonable assumption that this will be needed as well. @acouch, do you know of a way to achieve this with the method you are describing? – user842 Aug 9 '11 at 15:02

Check out Menu per Role Module. This module allows you to restrict access to menu items based on user roles. Once enabled, there will be a new fieldset that allows you to restrict access by role. The fieldset also appears in the node edit form.

| improve this answer | |

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.