1

I have a login menu item that links to the login page of my website. I want to have the menu item disappearing when someone is logged in and an a sign out button appearing in its place.

Since the menu item is not connected to a node, i cannot alter it's visibility based on node access rights. I found Menu Item Visibility module but it is beta and it does not seem to be maintained. Is there a way to do this via Drupal?

If I have to make a custom module or js can you give me a link of a tutorial on how to do this?

1

For login add a menu item into main menu named as Login and path should be user/login.

For logout add a menu item into main menu named as logout and path should be user/logout

Now when user will be login then login menu will replaced by logout automatically. And when he/she will be logout then a login menu will appear again.

5
  • Unfortunately the login procedure is handled by a custom module so in order to login I use a different url then user/login. Is there a way to do this manually? Aug 10 '15 at 11:04
  • if do you want manual work then you must mention in your question.
    – WaQaR Ali
    Aug 10 '15 at 11:31
  • you can use this snippet; <ul class="nav navbar-nav navbar-right"> <?php global $user; if($user->uid):?> <li> <a href="user/logout">Log Out </a></li> <?php else: ?> <li> <a href="/user">Log in</a></li> <?php endif; ?> </ul>
    – WaQaR Ali
    Aug 10 '15 at 11:35
  • Hello WaQar Ali, I am using TBmegamenu am I suppose to put this code in my php template? Aug 10 '15 at 12:03
  • not in template.php but use this code in page.tpl
    – WaQaR Ali
    Aug 10 '15 at 12:36

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.