Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By armanschwarz on
Hello,
I'm new to drupal, but not to php. This is probably a common question, but is there a way of making a login/logout button in the primary menu? I noticed I wasn't allowed to code php in the 'primary link' location or name. I noticed I was able to select which users (logged in or guest) see the secondary links, but this doesn't seem to be the case for primary links.
Surely there's some way of doing this without any major hacks? I appologise if this has already been posted but I couldn't find it anywhere, or in the documentation.
Comments
subscribing
In the hope there will be a useful answer (& applicable to Drupal 5 would be great).
I've searched for this and not found anything.
Just make two separate menu
Just make two separate menu options in the Primary Links menu... one that performs a login (call it "Log In" and let it path to "user/login") and one that perfoms a logout (call it "Log Out" and have it path to "logout"). Make their weights both -10 or something.
The core Drupal perms will only allow the logout link to appear when currently logged in, and the user/login link to appear only when not logged in. It will appear to toggle, but it's just being replaced as perms dictate.
Yes, that works!
Thank you so much!
Great thanks!
Great thanks!
thank you very much, I find
thank you very much, I find the way for long time, It works.
Any links is follow this rule? login and logout link in a block can smart filter?
---------------------
BUYERJOY
Upload
Thanks you so much for the information.
However I have a different menu that I want to make it visible in primary link and want to work it the same as Log In/Log Out. This menu is called "Submit Code". The path to this menu should be "/submit-code" if the member has already logged in. If it's not then it will directly go to "/user" to show the Log In form to the user.
Thanks in advance.
Download free source code
Its working!!!
Hey thanks alot.Its working fine.
Still works great!
Thanks. It does a great job.
This also really helped me,
This also really helped me, I'm on Drupal 6. Thanks!
Anisa.
Thanks it also works for me
Thanks it also works for me :)
Excellant work boss.
Excellant work boss. It help me a lot. Thank u so muchhhhhhhhhh!!!!!!!!!!!!
Suresh.E
Am a Acquia Certified Developer--Life Knocks us down. we have to decide whether or not to get up--
nice!
just what I was looking for ;)
thanks!
Fantastic
Just what I was looking for. Nice solution for a login button for anonymous users, and a logout for authenticated users :)
Cheers
My Drupal sites:
show username in logout link
Is there a way to show the current logged-in user's username in the logout link? So if my username was 'brian' the link would read 'Logout of Brian'?
Not in the standard Primary
Not in the standard Primary Links section, no. Not a way that I'm aware of. If you wanted to make your own menu in a block, you could place it there with some php code:
this is what I did and it seems to be working for me...
Just what I was looking for.
Just what I was looking for. Nice solution for a login button for anonymous users, and a logout for authenticated users :)
This is very helpful to everyone.
Thanks
Drupal
hello people new to Drupal not understanding as of now.
need to put Login/Logout link in all pages
I am using Drupal 6.16
I have gone through number of pages in Drupal but still not understanding how to place
Login and Logout link. I have removed the login and logout menu.
Logging in works by simply typing the .../login in url and the login page opens.
Same is the case with logout. It logs out when i type logout in url and press [Enter] .
But when I try making the buttons on primary menu by placing the url path it says :::
"The path 'mydomain.com/logout' is either invalid or you do not have access to it." (for logout)
"The path 'mydomain.com/login' is either invalid or you do not have access to it." (for login)
Thanks.
For myself I entered only
For myself I entered only "logout" in path.
No domain.com/ Just logout.
Link to my account
This is very usefull & can I get a 'My Profile' link next to 'logout' link for authenticated users.
Thanks.
status concerning drupal 7
does this 'dynamic logout/login' link work for drupal 7? I am running 7 and I don't believe it does. I always have both 'Login' and 'Logout' main menu links.
i meant to reply to the main thread here. sorry...
If you will simply follow the
If you will simply follow the code above:
http://drupal.org/node/264225#comment-2053912
You will now get both login/logout menu.
Drupal 7 Login/logout menu link
I believe the links in Drupal 7 Are:
Login: user/login
Logout: user/logout
the path solved my problem in
the path solved my problem in drupal 7. Thanks!
Thanks a lot
Thanks a lot
<?php global $user; if (
Irina Zaks,
irina.zaks@iringweb.com