Dynamic Login/Logout menu link

Need help with the Administration of your Joomla! 2.5 site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
ntonline
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Feb 25, 2011 6:23 am

Dynamic Login/Logout menu link

Post by ntonline » Mon Jan 30, 2012 3:34 am

Hello all,

I'm trying to make a menu item (Joomla 2.5), that will display "Login" if a user accessing the page is unregistered/not logged in, and will display "Logout" if a user is logged in. Does anyone have any suggestions how to do this?

Thanks
Last edited by humvee on Mon Jul 09, 2012 8:55 am, edited 1 time in total.
Reason: Marked as resolved

User avatar
jmuehleisen
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4874
Joined: Thu Nov 09, 2006 2:46 pm
Location: Kampala, Uganda
Contact:

Re: Dynamic Login/Logout menu link

Post by jmuehleisen » Mon Jan 30, 2012 4:12 am

This can be done, but it requires a few steps.

The first step is to set up Joomla to use a "Guest" mode. This is somewhat different than "Public" access, as Guest mode is active only when a user is not logged in.

Here's how to do that:

1. Create a new group in Users > Groups. Name it GUESTS. Select Parent Group as PUBLIC.

2. Goto Users > Options > Component tab. Select GUEST as the "Guest User Group" there.

3. Create a new ACL in Users > Acces Levels . Name it as GUEST USERS.

4. Edit GUESTS USERS ACL, which you just created and select GUESTS group to it. Dont add PUBLIC group to it.

5. Edit PUBLIC ACL and add GUEST USERS ACL to it.

6. Now you are done with the group and access level creation. Now goto Global Configuration and select DEFAULT ACCESS LEVEL as GUEST USERS.

Now that you have "guest" mode set up, you will create a menu item for the "Login" as usual (or edit your existing "login" if you have it.

Set the Access Level to Guest. That way it will show up only to non-logged in users.

Now, the next step is to create a "Logout" menu item that will show only to "registered" users.

Use this extension to make the "Logout" a simple, one click process:

http://extensions.joomla.org/extensions ... rect/17971

This creates a new menu item type that gives a quick, no confirmation logout.

Set the access level to be "Registered" and put it on the menu right next to your "Login" button.

The result is you have 2 menu items ... one for Login and one for Logout.

But, the Login button is only shown to non-logged in users, and the Logout button only appears to logged in users.

So, it appears to be a single menu item that "toggles" from "Login" to "Logout" ... but in reality is 2 different menu items.

See if that works for you.
John Muehleisen
Visit my "Getting Started with Joomla" site, now with videos, tips, and new user tutorials:  http://welcometojoomla.com

ntonline
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Feb 25, 2011 6:23 am

Re: Dynamic Login/Logout menu link

Post by ntonline » Mon Jan 30, 2012 5:00 am

Awesome! Works like a charm. Thanks John.

User avatar
jmuehleisen
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4874
Joined: Thu Nov 09, 2006 2:46 pm
Location: Kampala, Uganda
Contact:

Re: Dynamic Login/Logout menu link

Post by jmuehleisen » Mon Jan 30, 2012 5:34 am

Great! I'm glad that worked out for you.
John Muehleisen
Visit my "Getting Started with Joomla" site, now with videos, tips, and new user tutorials:  http://welcometojoomla.com

User avatar
Crazyhorse
Joomla! Intern
Joomla! Intern
Posts: 80
Joined: Fri Sep 18, 2009 2:16 pm
Contact:

Re: Dynamic Login/Logout menu link

Post by Crazyhorse » Sun Jul 08, 2012 11:52 am

Thanks, that is great...
Mostly old and in the way

User avatar
Nick Savov
Joomla! Ace
Joomla! Ace
Posts: 1076
Joined: Tue Apr 13, 2010 7:40 pm

Re: Dynamic Login/Logout menu link

Post by Nick Savov » Sun Aug 12, 2012 4:57 am

Thank you, John! This worked really well!

By the way, Joomla 3 will have a guest user access level, etc, within the core :)

Kind regards,
Nick
Joomla Templates created by the Wright Framework.

"God is most glorified in us, when we are most satisfied in Him" - http://www.desiringgod.org/

ozwest
Joomla! Intern
Joomla! Intern
Posts: 72
Joined: Thu Apr 10, 2008 5:22 am
Location: Perth, Western Australia
Contact:

Re: Dynamic Login/Logout menu link

Post by ozwest » Fri Aug 17, 2012 7:34 am

Fantastic, thank you very much.

ruud68
Joomla! Apprentice
Joomla! Apprentice
Posts: 38
Joined: Tue Jan 24, 2012 7:23 pm

Re: Dynamic Login/Logout menu link

Post by ruud68 » Mon Aug 20, 2012 5:39 pm

Hi,

been using the proposed solution for a while now: no problems... worked like a charm...

Now I update my servers php version from version 5.2.17 to 5.3.8 and it doesn't work anymore?

when logged in, it stil shows the menu entry 'login' that has 'guest' access only...
very strange, my production site is stil on php 5.2.17 and stil works okay.

anyone any pointers? Am I missing something?

thanks in advance,
Ruud.

User avatar
jmuehleisen
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4874
Joined: Thu Nov 09, 2006 2:46 pm
Location: Kampala, Uganda
Contact:

Re: Dynamic Login/Logout menu link

Post by jmuehleisen » Mon Aug 20, 2012 6:27 pm

Rudd,

If you are using the "Quick Logout" component, try updating it to the latest version (1.8.0) if you have not already done so.

Then, edit the menu item that you are using for the "Quick Logout."

Double check the setting for the "Redirect to Page on Logout" ... I've seen some errors disappear when this is edited and the page is re-selected.

Let us know how it goes.
John Muehleisen
Visit my "Getting Started with Joomla" site, now with videos, tips, and new user tutorials:  http://welcometojoomla.com

ruud68
Joomla! Apprentice
Joomla! Apprentice
Posts: 38
Joined: Tue Jan 24, 2012 7:23 pm

Re: Dynamic Login/Logout menu link

Post by ruud68 » Mon Aug 20, 2012 6:36 pm

Hi John,
thanks for looking into this.
Only just installed the Quick Logout component, the issue is there with and without this component.
Strange thing is that I restored my working production site to my server with php 5.2.17: it worked > upgraded php to version 5.3.8 and it stopped working...

Is there some way I can troubleshoot and give additional information / logs?

thanks again,
Ruud.

User avatar
Nick Savov
Joomla! Ace
Joomla! Ace
Posts: 1076
Joined: Tue Apr 13, 2010 7:40 pm

Re: Dynamic Login/Logout menu link

Post by Nick Savov » Mon Aug 20, 2012 7:29 pm

Hi Ruud,

Double check everything on your end. I'm using 5.3.8 and it works well for me.

Kind regards,
Nick
Joomla Templates created by the Wright Framework.

"God is most glorified in us, when we are most satisfied in Him" - http://www.desiringgod.org/

User avatar
jmuehleisen
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4874
Joined: Thu Nov 09, 2006 2:46 pm
Location: Kampala, Uganda
Contact:

Re: Dynamic Login/Logout menu link

Post by jmuehleisen » Tue Aug 21, 2012 2:02 am

Rudd,

So, if I understand you correctly, the issue seems to be that the "Login" menu item, which is set to show in "Guest" mode only, is still showing, even when the user is logged in.

And this happens only when php 5.3 is being used ... the "proper" behavior returns when you revert back to php 5.2.

Let me experiment also a bit more here.

Or, have I misunderstood?

John
John Muehleisen
Visit my "Getting Started with Joomla" site, now with videos, tips, and new user tutorials:  http://welcometojoomla.com

ruud68
Joomla! Apprentice
Joomla! Apprentice
Posts: 38
Joined: Tue Jan 24, 2012 7:23 pm

Re: Dynamic Login/Logout menu link

Post by ruud68 » Tue Aug 21, 2012 5:50 am

jmuehleisen wrote:Rudd,

So, if I understand you correctly, the issue seems to be that the "Login" menu item, which is set to show in "Guest" mode only, is still showing, even when the user is logged in.

And this happens only when php 5.3 is being used ... the "proper" behavior returns when you revert back to php 5.2.

Let me experiment also a bit more here.

Or, have I misunderstood?

John
correct...
maybe it depends on a php function or module that is not available or different in php 5.3.8.
Unfortunately I am not a developer so cannot pinpoint any further :(
thanks again.
regards,
Ruud.

User avatar
jmuehleisen
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4874
Joined: Thu Nov 09, 2006 2:46 pm
Location: Kampala, Uganda
Contact:

Re: Dynamic Login/Logout menu link

Post by jmuehleisen » Tue Aug 21, 2012 6:47 am

Rudd,

Thanks for the confirmation.

I just tested this on a new site that is using php 5.3, and the "guest mode" works as it should on this site.

The "Login" button that I have set to show only in "guest" mode disappears then logged in, and reappears when logged out.

So, I am not able to duplicate what you are experiencing.

I would suggest that you review this earlier posting in this thread.

http://forum.joomla.org/viewtopic.php?f ... 7#p2731534

Check each step to make sure the settings are right here.

Perhaps something got messed up here that is causing this to break.

But that's just a guess. It should work regardless of whether you are using php 5.2 or 5.3. As far as I know, there is not a function or module that is no longer available in 5.3.

But, go back and check the settings step by step again. It just might make a difference.

Let us know how it goes.
John Muehleisen
Visit my "Getting Started with Joomla" site, now with videos, tips, and new user tutorials:  http://welcometojoomla.com

ruud68
Joomla! Apprentice
Joomla! Apprentice
Posts: 38
Joined: Tue Jan 24, 2012 7:23 pm

Re: Dynamic Login/Logout menu link

Post by ruud68 » Fri Aug 24, 2012 2:38 am

Hi John,

thanks again for looking into this and thinking along.
strange thing is that when I do a restore (kickstart with Akeeba backup) from my production site, all settings are identical: only on production it works and on my acc environment not :( only change is php upgrade that I need to test because some modules are requiring it.

I have followed the instructions by the letter, even tried to delete all guest changes (which was not possible: keeps on nagging that guest users viewing acl is in use)
But cannot change its behavior.

just thought: lets remove my browsers cookies for my website (acc)... perhaps the user state is in there somehow... and I lost my login menu entry altogether only to have it reappear when I choose to accept cookies again.

the plot thickens :(

will do some more testing and report back.

thanks for your patience,
regards,
Ruud.

ruud68
Joomla! Apprentice
Joomla! Apprentice
Posts: 38
Joined: Tue Jan 24, 2012 7:23 pm

Solved: Dynamic Login/Logout menu link

Post by ruud68 » Fri Aug 24, 2012 6:03 am

Hi,

just to let you (and everybody running into this issue) know I found the 'solution'.
Because of European legislation I have installed the e-privacy plugin.
This plugin stops cookies from being installed and prompts the guest to explicitly accept the use of cookies...
This plugin has the possibility of advanced settings among which the use of a geo plugin and view level. The geo plugin cannot be used on my server: it states that my version of php lacks the PHP Reflection classes; as a result, this feature is not available on your server. For this reason also the view level cannot be filled in.

Now I have upgraded my PHP to version 5.3.8 which as it turns out does have the reflection classes and now that the view level is showing it shows 'Guest' as view level!!! Changing that to Public solves the issue.

I have already contacted the developer of the plugin, just wanted to share here :)

Thanks for looking into this with me!
regards,
Ruud.

User avatar
Crazyhorse
Joomla! Intern
Joomla! Intern
Posts: 80
Joined: Fri Sep 18, 2009 2:16 pm
Contact:

Re: Dynamic Login/Logout menu link

Post by Crazyhorse » Fri Aug 24, 2012 6:12 am

Thanks for this Ruud... I have been having problems with other things in Joomla (latest Akeeba Backup for instance) because of PHP5.2.17 and on another forum I was told that Joomla 2.5 requires PHP5.3... problem is figuring out how to get shared hosting company to upgrade to 5.3...
Regard Philip
Mostly old and in the way

User avatar
jmuehleisen
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4874
Joined: Thu Nov 09, 2006 2:46 pm
Location: Kampala, Uganda
Contact:

Re: Dynamic Login/Logout menu link

Post by jmuehleisen » Fri Aug 24, 2012 7:33 am

Very interesting, and thanks for figuring that out.

@Crazyhorse ... on my host, I can bump up the php version from the default 5.2 to 5.3 by adding a few lines to my .htaccess file.

Not sure if your host takes that approach (I'm using HostGator in this instance).

For example, on HG adding this to the .htaccess file causes the site to run under php 5.3:

Code: Select all

Action application/x-hg-php53 /cgi-sys/php53
AddType application/x-httpd-php53 .php
John Muehleisen
Visit my "Getting Started with Joomla" site, now with videos, tips, and new user tutorials:  http://welcometojoomla.com

User avatar
Crazyhorse
Joomla! Intern
Joomla! Intern
Posts: 80
Joined: Fri Sep 18, 2009 2:16 pm
Contact:

Re: Dynamic Login/Logout menu link

Post by Crazyhorse » Fri Aug 24, 2012 1:49 pm

Thanks John that was very helpful and worked... well knowing what I was looking for I found that AddHandler x-mapp-php6 .php gave me PHP5.4.5. All I need to do know is to be able to get a cron job to use that that and I might be able to get Akeebabackup to work on cron.

Sorry about the severe topic drift....

Philip
Mostly old and in the way

molsonbubba
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Fri Nov 02, 2012 2:36 pm

Re: Dynamic Login/Logout menu link

Post by molsonbubba » Sun Dec 30, 2012 7:09 pm

Wont work in Joomla 2.5.8. I had followed above instructions but when setting my main menu to Guest Users as access level I can no longer see the menu at all.

User avatar
jmuehleisen
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4874
Joined: Thu Nov 09, 2006 2:46 pm
Location: Kampala, Uganda
Contact:

Re: Dynamic Login/Logout menu link

Post by jmuehleisen » Sun Dec 30, 2012 7:30 pm

Sorry you are running into problems here.
when setting my main menu to Guest Users as access level
Just to be clear here, you don't want to set the access level for the whole menu to be "Guest" ... just the "Login" menu item.

So, if you have set your main menu (with all of the menu items on it) to "guest" then it will indeed disappear.

It is just the single "Login" item that should be set to "guest."

Or, am I misunderstanding what you are saying here?
John Muehleisen
Visit my "Getting Started with Joomla" site, now with videos, tips, and new user tutorials:  http://welcometojoomla.com

User avatar
Nick Savov
Joomla! Ace
Joomla! Ace
Posts: 1076
Joined: Tue Apr 13, 2010 7:40 pm

Re: Dynamic Login/Logout menu link

Post by Nick Savov » Sun Dec 30, 2012 7:33 pm

Hi molsonbubba,

Try going through the steps again as it works on the 2.5.8 site that I'm using.

Kind regards,
Nick
Joomla Templates created by the Wright Framework.

"God is most glorified in us, when we are most satisfied in Him" - http://www.desiringgod.org/

molsonbubba
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Fri Nov 02, 2012 2:36 pm

Re: Dynamic Login/Logout menu link

Post by molsonbubba » Sun Dec 30, 2012 7:45 pm

John, thank you so much! Got it to work. Much appreciate quick and clear reply!
Nick, thank you for replying, got it working now :)

User avatar
jmuehleisen
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4874
Joined: Thu Nov 09, 2006 2:46 pm
Location: Kampala, Uganda
Contact:

Re: Dynamic Login/Logout menu link

Post by jmuehleisen » Sun Dec 30, 2012 7:47 pm

Very good. I'm glad that you got it worked out quickly.
John Muehleisen
Visit my "Getting Started with Joomla" site, now with videos, tips, and new user tutorials:  http://welcometojoomla.com

annasky
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Mon May 13, 2013 11:21 am

Re: Dynamic Login/Logout menu link

Post by annasky » Mon May 13, 2013 11:28 am

Hi,

Sorry to revive a slightly older post - I've followed the steps to have the dynamic login/logout link in J3.1.1 and that part of it worked. However, when logged in to the front end I now cannot edit my profile, due to a 403 error.

After testing, I've pinpointed it to the access level on the login link - if it's set to public, then I can see the profile and am able to edit it when logged in, and can see both the login and logout buttons (as expected).

If it's set to guest, then I get the dreaded 403 error.

I'm assuming there's extra permissions I can tweak somewhere, but that's one area of Joomla! that I have no experience with whatsoever, so I would really appreciate a push in the right direction.

Many thanks,
Anna

User avatar
jmuehleisen
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4874
Joined: Thu Nov 09, 2006 2:46 pm
Location: Kampala, Uganda
Contact:

Re: Dynamic Login/Logout menu link

Post by jmuehleisen » Mon May 13, 2013 12:25 pm

Dear Anna,

First of all, welcome to the Joomla forum.

Sorry you are running into problems here. I'll be glad to take a look at this and see if I can see what might be happening here.

I'll get back to you.

John
John Muehleisen
Visit my "Getting Started with Joomla" site, now with videos, tips, and new user tutorials:  http://welcometojoomla.com

User avatar
jmuehleisen
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4874
Joined: Thu Nov 09, 2006 2:46 pm
Location: Kampala, Uganda
Contact:

Re: Dynamic Login/Logout menu link

Post by jmuehleisen » Mon May 13, 2013 12:46 pm

Anna,

I have set this up on my test site (Joomla 3.1.1) and am not getting an error accessing the user profile, as you are.

Hmmm.

I'll be glad to take a look, if you'd like.

On this forum, you cannot send "private messages" until you have 5 posts, so, since you are new, you cannot send me a private message with login information.

But, if you'd like me to take a look, send an email to me at john@welcometojoomla.com and I'll be happy to take a look for you.

John
John Muehleisen
Visit my "Getting Started with Joomla" site, now with videos, tips, and new user tutorials:  http://welcometojoomla.com

User avatar
lausianne
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 162
Joined: Thu Apr 06, 2006 3:15 pm

Re: Dynamic Login/Logout menu link

Post by lausianne » Sat Jul 27, 2013 8:56 am

Hi,
somehow I can't figure out how to correctly redirect to the home page on logout. There are several questions on this in the "official"(?) support site: http://joomlacode.org/gf/project/com_qu ... m_id=16304
I have a hidden menu item set up for "home", but that page is loaded without modules on logout. The page I actually want to redirect to is simply "/index.php".
Thanks!
Ralf.

( J!2.5.13, QuickLogout 1.8 )

User avatar
jmuehleisen
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4874
Joined: Thu Nov 09, 2006 2:46 pm
Location: Kampala, Uganda
Contact:

Re: Dynamic Login/Logout menu link

Post by jmuehleisen » Sat Jul 27, 2013 10:12 am

Thanks for your question.

(And thanks for letting me know there are some unanswered questions on the Joomlacode forum ... I was not aware that they were there).

Try this. Instead of using a "hidden" home page menu item, try using your "real" home page as the redirect page.

See if that makes any difference in how Quick Logout acts.

Let me know how it goes. I'll be happy to try to help you sort this out.
John Muehleisen
Visit my "Getting Started with Joomla" site, now with videos, tips, and new user tutorials:  http://welcometojoomla.com

User avatar
lausianne
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 162
Joined: Thu Apr 06, 2006 3:15 pm

Re: Dynamic Login/Logout menu link

Post by lausianne » Sat Jul 27, 2013 11:55 am

Thanks for the quick reply.
 Instead of using a "hidden" home page menu item, try using your "real" home page as the redirect page.
That's exactly the question. An embarrassing one perhaps, it must be simple ... how do I redirect to the real home page?


Locked

Return to “Administration Joomla! 2.5”