When an anonymous user comes to the site, the last item in the Primary Links needs to say Login. However, if they are logged in, it needs to say Account.
Whats the easiest way to achieve this in code?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I accomplish this by using the me aliases module to generate one single path for the account page of the logged in user (e.g.
user/me) and adding bothuser/meanduser/loginto the menu.If you wanted to do this programmatically, you’d use
menu_link_save():Due to the way Drupal handles menu permissions, a logged in user will not see Login (logged in users do not have access to
user/login) but will see Account, and logged out users will see Login but won’t see Account (anonymous users do not have access touser/me).