Login / Logout Link

Everything to do with Joomla! 1.5 templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Jojomofo
Joomla! Apprentice
Joomla! Apprentice
Posts: 31
Joined: Mon May 26, 2008 5:36 pm

Login / Logout Link

Postby Jojomofo » Sat Sep 13, 2008 9:08 am

Hi Guys,

At the moment i have a login form on my template as default by joomla. I feel it takes up space of my template. How can i have a Login / Logout link? Most sites have these. So when you login it will display something like "account / logout" and when loged out it will display "login"

Thanks for any help! :)

shinta2
Joomla! Apprentice
Joomla! Apprentice
Posts: 33
Joined: Thu Mar 09, 2006 3:49 pm

Re: Login / Logout Link

Postby shinta2 » Wed Sep 17, 2008 7:11 pm

I'm also interested in this. I've searched the forums and the web for this issue, but I've found no working solution for 1.5. I've only found posts asking this question, like this one ;)

BTW, "index.php?com_user&task=logout" doesn't seem to work anymore; I remember it used to? All I really need is a way to create a menu link that logs out the user, then I can use some simple php in the template to toggle between the two. But I don't know what the link should be for a "logout" menu item, or if there's a buil-in menu item type like there is for "login."

Thanks.

j916
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Thu Aug 28, 2008 7:17 pm
Contact:

Re: Login / Logout Link

Postby j916 » Thu Sep 25, 2008 4:04 pm

Did you have any luck in finding a solution? I just started looking for the same thing.

-Jeff

blackmagic911
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Jun 01, 2008 8:26 am

Re: Login / Logout Link

Postby blackmagic911 » Sun Nov 02, 2008 10:08 am

I also have the same question. It would make my frontpage much more simple. any answers?

refernow
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Nov 02, 2008 5:07 pm

Re: Login / Logout Link

Postby refernow » Sun Nov 02, 2008 5:19 pm

I have created a Request Form for clients but can't find a way to create a text link. Please share if you got solution.

User avatar
redmars
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Thu Mar 30, 2006 3:33 pm
Location: NY
Contact:

Re: Login / Logout Link

Postby redmars » Fri Nov 07, 2008 5:20 am

If your just wanting to add a link in your html code, you just need to put this link if you have Search Engine Friendly URLs turned on.
http://www.yourdomain.com/logout.html

In one of my site I have added a logout link in the main menu, using the "Default Login Layout" for the Menu Item Type. It shows up as logout when a user is logged in.

Image

User avatar
tr2n
Joomla! Intern
Joomla! Intern
Posts: 51
Joined: Thu Nov 13, 2008 7:32 pm
Location: Mexico

Re: Login / Logout Link

Postby tr2n » Fri Dec 19, 2008 7:49 pm

This works:
/index.php?option=com_user&view=login&task=logout

Hope it helps.. :pop

User avatar
Whitebread
Joomla! Apprentice
Joomla! Apprentice
Posts: 27
Joined: Wed Dec 17, 2008 6:27 pm
Contact:

Re: Login / Logout Link

Postby Whitebread » Fri Jan 23, 2009 8:28 pm

thanks tr2n...

This worked well for me with one exception, when I logout it takes me to a blank page and stays there. Is there any code that could be added to that link that would re-direct me to a certain page? say, the login page?
Jason P Bunn
Web Developer
http://www.virburbia.com

User avatar
tr2n
Joomla! Intern
Joomla! Intern
Posts: 51
Joined: Thu Nov 13, 2008 7:32 pm
Location: Mexico

Re: Login / Logout Link

Postby tr2n » Fri Jan 23, 2009 9:34 pm

Umm.. I'm guessing a redirect to another page must be added into the logout task of the com_user controller.php file.. lemme check and see if it works.

fr33lanc3
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed Feb 04, 2009 10:23 am

Re: Login / Logout Link

Postby fr33lanc3 » Wed Feb 04, 2009 10:26 am

This page will explain about the logout link redirect.
viewtopic.php?f=428&t=334765

fr33lanc3
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed Feb 04, 2009 10:23 am

Re: Login / Logout Link

Postby fr33lanc3 » Wed Feb 04, 2009 10:32 am

Also, this is link text for login:

index.php?option=com_user&view=login&Itemid=33

User avatar
tr2n
Joomla! Intern
Joomla! Intern
Posts: 51
Joined: Thu Nov 13, 2008 7:32 pm
Location: Mexico

Re: Login / Logout Link

Postby tr2n » Wed Feb 04, 2009 4:50 pm

Yay, the info on that post works great, use this link instead to return to the index:

index.php?option=com_user&task=logout&return=Lw

User avatar
frankzusa
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Tue Mar 17, 2009 6:00 pm

Re: Login / Logout Link

Postby frankzusa » Wed Mar 25, 2009 2:25 pm

Thank to tr2n for the link!!! Cheer!

chilts
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Tue Nov 20, 2007 4:23 am

Re: Login / Logout Link

Postby chilts » Wed Apr 29, 2009 11:08 pm

good post. was looking exactly for this. thanks.

njjacob
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 144
Joined: Fri Oct 13, 2006 3:58 am
Contact:

Re: Login / Logout Link

Postby njjacob » Thu Apr 30, 2009 4:38 pm

actually just use

http://www.yourdomain.com/index.php?option=com_login for the login...

User avatar
tr2n
Joomla! Intern
Joomla! Intern
Posts: 51
Joined: Thu Nov 13, 2008 7:32 pm
Location: Mexico

Re: Login / Logout Link

Postby tr2n » Thu Apr 30, 2009 5:12 pm

Yeah, without &Itemid for the login.. actually for any generic link :) adjust the Itemid for your own site.

User avatar
imscoop22
Joomla! Explorer
Joomla! Explorer
Posts: 255
Joined: Sat Mar 10, 2007 9:09 pm
Contact:

Re: Login / Logout Link

Postby imscoop22 » Tue Jun 16, 2009 1:00 pm

For the original question, see if this helps. I wrote it because a variation of this question was posted again recently.

http://www.joomlafare.com/joomla/joomla ... -to-logout

peterleslie
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Mon Dec 07, 2009 12:32 am

Re: Login / Logout Link

Postby peterleslie » Thu Dec 17, 2009 1:06 am

tr2n - many thanks your post solved a problem that has been bugging me re-direct logout link

muchos gracias

msibley
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Thu Jan 28, 2010 4:41 pm
Location: UK
Contact:

Re: Login / Logout Link

Postby msibley » Thu Feb 18, 2010 12:07 pm

Thanks tr2n, your method worked a treat except for one slight issue. The home URL for my particular installation wasn't the root as Joomla was installed in a sub-folder which meant I was getting redirected to the parent directory on logout. The solution is easy enough though:

Code: Select all

<a href="index.php?option=com_user&task=logout&return=<?php echo $returnURL; ?>">Logout</a>


Then just set $returnURL to the homepage using:

Code: Select all

$returnURL = base64_encode(JURI::root() . "\n");

emediately
Joomla! Apprentice
Joomla! Apprentice
Posts: 32
Joined: Sat Aug 08, 2009 5:37 am

Re: Login / Logout Link

Postby emediately » Fri Jun 11, 2010 11:16 pm

How can I make the same login button that RETURNS to the SAME page the user was on after loggining in???

Because it's pointless if some browses your site and they need to login at a point, and then all of a sudden it directs them to the homepage of my website..

Please help.. What's the PHP query (return url) for the same url the user was on before logging in?

Also.. What changes do I need to make in the core to change the login page so it would direct to the page the user was on?

msibley wrote:Thanks tr2n, your method worked a treat except for one slight issue. The home URL for my particular installation wasn't the root as Joomla was installed in a sub-folder which meant I was getting redirected to the parent directory on logout. The solution is easy enough though:

Code: Select all

<a href="index.php?option=com_user&task=logout&return=<?php echo $returnURL; ?>">Logout</a>


Then just set $returnURL to the homepage using:

Code: Select all

$returnURL = base64_encode(JURI::root() . "\n");

rtenhave34
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed Jun 16, 2010 10:27 am

Re: Login / Logout Link

Postby rtenhave34 » Mon Jul 05, 2010 9:31 am

@ emediately: Sorry, I do not have the answer to your query....

@ All:

I have been playing around with this as I was facing the same issue. No coding needed (in the end) to get exactly what I wanted though (providing your return page can be the homepage of your site).....

1. Create a Login link (Public) in one of your exsisting menu's
2. Create a "User Menu" (Registered) which will show up when logged in
3. Put all relevant menu choices in there (Edit, Lost Password, etc)
4. Create a "Login"menu item, but name it "Logout" and set it to "Registered"

Now, the Logout menu option will appear in the User Menu, only when logged in, and when clicked it will tell you that you are logged in, but will show a Logout button on the same page.

PS, Dont forget to set your Landing and End URL's in the "Login" option panel!

Presto!

djohnson1215
Joomla! Explorer
Joomla! Explorer
Posts: 370
Joined: Fri Jun 13, 2008 7:49 pm
Location: Escondido, CA 92026
Contact:

Re: Login / Logout Link

Postby djohnson1215 » Fri Aug 13, 2010 3:18 pm

Nice. Very good discussion. Good thinking rtenhave34.

But my need is just a little different. My client wants a link (not a menu item) to change from login to logout. The link would be dynamic depending on whether a user is login already. When not logged in, the link would read "login". After login, the link would read "logout" and apply the URL path in earlier posts to log the user out.

I know how to do this in a menu item thanks to rtenhave34's suggestions. But how would I do this for a typical <a> tag link. My suspicion is that this will take some php which I really don't know well.

As an alternative, the link could be a image button. The first button would be a login button. When the user is logged in, they see the logout button.

Again, I am not a PHP programmer, but I am sure some of the subscribers to this thread are. So I am appealing to those who would like to take up the challenge and write a little code to make this work. It would be a really nice addition to Joomla sites.

After a bit of research, I have found the JFactory function that looks like it would work: http://docs.joomla.org/JFactory/getUser .

I am just guessing, but I suspect the PHP code needs to look something like this:

Code: Select all

<?php $user =& JFactory::getUser();
if ($user->id == 0){   
echo '<a href="/registration-login.html" >Login</a>';}
else {   
echo '<a href="/index.php?option=com_user&task=logout&return=Lw" >Logout</a>';}
?>


Now, how do you get this php code into an article running joomla 1.5.20? Anyone up for a challenge?
D. Johnson
Technology is our advantage;
performance our passion

http://www.positionresearch.com

djohnson1215
Joomla! Explorer
Joomla! Explorer
Posts: 370
Joined: Fri Jun 13, 2008 7:49 pm
Location: Escondido, CA 92026
Contact:

Re: Login / Logout Link

Postby djohnson1215 » Fri Aug 13, 2010 11:14 pm

It worked!!!!

Had to make a module with Jumi to get PHP to work. And then had to put all the other links in the head nav inside the php, but it worked!

Final Code:

Code: Select all

<?php $user =& JFactory::getUser();
if ($user->id == 0){   
echo '<p style="margin-right:30px; padding:5px 0 10px 0; color: #ffffff; font-size: 13px; font-weight: 900;"><a target="_self" title="All About FoIP Home" href="http://www.allaboutfoip.com/">Home</a> |<a title="About Us" href="/about-us.html">About Us</a> | <a href="/contact-us.html">Contact Us</a>       <a><span style="color: #0000ff;"> </span></a> <a  class="login_lnk" target="_self" title="Login" href="/registration-login.html"><img src="images/allaboutfoip/login.png" alt="" height="20px width="60px" /></a></p>';}
else {   
echo '<p style="margin-right:30px; padding:5px 0 10px 0; color: #ffffff; font-size: 13px; font-weight: 900;"><a target="_self" title="All About FoIP Home" href="http://www.allaboutfoip.com/">Home</a> |<a title="About Us" href="/about-us.html">About Us</a> | <a href="/contact-us.html">Contact Us</a> <a><span style="color: #0000ff;"> </span></a>      <a class="logout_lnk" target="_self" title="Logout" href="/index.php?option=com_user&task=logout&return=Lw" ><img src="images/allaboutfoip/logout.png" alt="" height="20px width="60px" /></a></p>';}
?>


See it in top right here: http://www.allaboutfoip.com/

PHP programmer level .01 strikes again :-)
D. Johnson
Technology is our advantage;
performance our passion

http://www.positionresearch.com

User avatar
imscoop22
Joomla! Explorer
Joomla! Explorer
Posts: 255
Joined: Sat Mar 10, 2007 9:09 pm
Contact:

Re: Login / Logout Link

Postby imscoop22 » Sat Aug 14, 2010 1:01 am

It's interesting that this thread pops back up every now and then.

@djohnson1215 - You can use MetaMod to swap modules like I described in the link I posted earlier in this thread. The modules you "swap" do not need to be menu modules...they could just be Custom HTML modules. I think that would be a bit easier to manage than the method you used.

djohnson1215
Joomla! Explorer
Joomla! Explorer
Posts: 370
Joined: Fri Jun 13, 2008 7:49 pm
Location: Escondido, CA 92026
Contact:

Re: Login / Logout Link

Postby djohnson1215 » Mon Aug 16, 2010 3:04 pm

Hi imscoop22,

I just checked "MetaMod". Very nice. It does look like "MetaMod" would do the same thing since it claims to:

"show/hide modules for individual users, guests, logged-in users, or any user group"

Nice find. Will definitely keep this module in mind for next time. Tks for the heads up!
D. Johnson
Technology is our advantage;
performance our passion

http://www.positionresearch.com

Tzakuk
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed May 19, 2010 4:27 am

Re: Login / Logout Link

Postby Tzakuk » Mon Sep 20, 2010 9:19 pm


wwwstalcup
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Wed Dec 08, 2010 12:08 am
Location: Texas and Beyond
Contact:

Re: Login / Logout Link

Postby wwwstalcup » Mon Jun 06, 2011 3:18 am

I have also found in 1.5.23 if you use this for front side access:
<a href="index.php?option=com_user&view=login">Login-Logout</a> to create your link it will log them & go back to home page (even if that's in a sub-dir) but not the page they were on. So, a user can login and then navigate to edit - which was what my client wanted to do ( or whatever else "logged in" brings on your site). If they click the Login-Logout link again but are logged in, they get the logout screen, & on doing so return to the site local home page (even if in a sub-dir).

might be a simple alt for some sites.

Wes.
World Wide Wes Stalcup
http://www.OnlyWEBS.us

FranCardin
Joomla! Apprentice
Joomla! Apprentice
Posts: 38
Joined: Wed Jul 13, 2011 5:02 am

Re: Login / Logout Link

Postby FranCardin » Sat Mar 03, 2012 8:10 am

People who are still struggling with this please check-out this tutorial
http://docs.joomla.org/Access_Control_List/1.6-2.5/Tutorial#Allowing_Guest-Only_Access_to_Menu_Items_and_Modules
to create 'Guest' User Group.

After you create the above 'Guest' user group, Create two 'Login' Menus.
One you name as 'Login' and Set access level to 'Guest'
and the second one rename as 'Logout' & Set access level to 'Registered'

That's it. You can keep 'ordering' of the two menu to close to each other. (See the attached image)
login_logout.jpg


Now, after you log in from the frontend you will see that the 'Login' menu automatically changes to 'Logout'

Thanks.
You do not have the required permissions to view the files attached to this post.

deadlydave
Joomla! Apprentice
Joomla! Apprentice
Posts: 23
Joined: Thu Oct 25, 2007 6:23 pm
Location: London UK
Contact:

Re: Login / Logout Link

Postby deadlydave » Tue Apr 17, 2012 11:25 am

please note the above post only applies to joomla 1.6 and above

merc911
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Sat May 19, 2012 7:39 pm

Re: Login / Logout Link

Postby merc911 » Sun Jul 22, 2012 7:30 pm

In which case is there anythig for 2.5?.
I have a login menu button. I cant see how to create a logout button.


Return to “Templates for Joomla! 1.5”

Who is online

Users browsing this forum: No registered users and 10 guests