The Joomla! Forum ™



Forum rules


Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.



Post new topic Reply to topic  [ 40 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Login / Logout Link
PostPosted: Sat Sep 13, 2008 9:08 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon May 26, 2008 5:36 pm
Posts: 31
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! :)


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Wed Sep 17, 2008 7:11 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Mar 09, 2006 3:49 pm
Posts: 33
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.


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Thu Sep 25, 2008 4:04 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Aug 28, 2008 7:17 pm
Posts: 9
Did you have any luck in finding a solution? I just started looking for the same thing.

-Jeff


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Sun Nov 02, 2008 10:08 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sun Jun 01, 2008 8:26 am
Posts: 3
I also have the same question. It would make my frontpage much more simple. any answers?


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Sun Nov 02, 2008 5:19 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sun Nov 02, 2008 5:07 pm
Posts: 3
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.


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Fri Nov 07, 2008 5:20 am 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Mar 30, 2006 3:33 pm
Posts: 17
Location: NY
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


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Fri Dec 19, 2008 7:49 pm 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Thu Nov 13, 2008 7:32 pm
Posts: 51
Location: Mexico
This works:
/index.php?option=com_user&view=login&task=logout

Hope it helps.. :pop


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Fri Jan 23, 2009 8:28 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Dec 17, 2008 6:27 pm
Posts: 27
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


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Fri Jan 23, 2009 9:34 pm 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Thu Nov 13, 2008 7:32 pm
Posts: 51
Location: Mexico
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.


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Wed Feb 04, 2009 10:26 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Wed Feb 04, 2009 10:23 am
Posts: 2
This page will explain about the logout link redirect.
viewtopic.php?f=428&t=334765


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Wed Feb 04, 2009 10:32 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Wed Feb 04, 2009 10:23 am
Posts: 2
Also, this is link text for login:

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


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Wed Feb 04, 2009 4:50 pm 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Thu Nov 13, 2008 7:32 pm
Posts: 51
Location: Mexico
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


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Wed Mar 25, 2009 2:25 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Mar 17, 2009 6:00 pm
Posts: 14
Thank to tr2n for the link!!! Cheer!


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Wed Apr 29, 2009 11:08 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Nov 20, 2007 4:23 am
Posts: 18
good post. was looking exactly for this. thanks.


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Thu Apr 30, 2009 4:38 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Fri Oct 13, 2006 3:58 am
Posts: 144
actually just use

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


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Thu Apr 30, 2009 5:12 pm 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Thu Nov 13, 2008 7:32 pm
Posts: 51
Location: Mexico
Yeah, without &Itemid for the login.. actually for any generic link :) adjust the Itemid for your own site.


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Tue Jun 16, 2009 1:00 pm 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Sat Mar 10, 2007 9:09 pm
Posts: 255
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

_________________
http://twitter.com/imscoop22
<><


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Thu Dec 17, 2009 1:06 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Dec 07, 2009 12:32 am
Posts: 5
tr2n - many thanks your post solved a problem that has been bugging me re-direct logout link

muchos gracias


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Thu Feb 18, 2010 12:07 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Thu Jan 28, 2010 4:41 pm
Posts: 2
Location: UK
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:
<a href="index.php?option=com_user&task=logout&return=<?php echo $returnURL; ?>">Logout</a>


Then just set $returnURL to the homepage using:
Code:
$returnURL = base64_encode(JURI::root() . "\n");


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Fri Jun 11, 2010 11:16 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Aug 08, 2009 5:37 am
Posts: 32
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:
<a href="index.php?option=com_user&task=logout&return=<?php echo $returnURL; ?>">Logout</a>


Then just set $returnURL to the homepage using:
Code:
$returnURL = base64_encode(JURI::root() . "\n");


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Mon Jul 05, 2010 9:31 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Wed Jun 16, 2010 10:27 am
Posts: 2
@ 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!


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Fri Aug 13, 2010 3:18 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Fri Jun 13, 2008 7:49 pm
Posts: 370
Location: Escondido, CA 92026
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:
<?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


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Fri Aug 13, 2010 11:14 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Fri Jun 13, 2008 7:49 pm
Posts: 370
Location: Escondido, CA 92026
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:
<?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


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Sat Aug 14, 2010 1:01 am 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Sat Mar 10, 2007 9:09 pm
Posts: 255
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.

_________________
http://twitter.com/imscoop22
<><


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Mon Aug 16, 2010 3:04 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Fri Jun 13, 2008 7:49 pm
Posts: 370
Location: Escondido, CA 92026
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


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Mon Sep 20, 2010 9:19 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed May 19, 2010 4:27 am
Posts: 8
http://docs.joomla.org/Customising_the_ ... orm_module


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Mon Jun 06, 2011 3:18 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Dec 08, 2010 12:08 am
Posts: 9
Location: Texas and Beyond
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


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Sat Mar 03, 2012 8:10 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Jul 13, 2011 5:02 am
Posts: 27
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)
Attachment:
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.


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Tue Apr 17, 2012 11:25 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Oct 25, 2007 6:23 pm
Posts: 23
Location: London UK
please note the above post only applies to joomla 1.6 and above


Top
 Profile  
 
 Post subject: Re: Login / Logout Link
PostPosted: Sun Jul 22, 2012 7:30 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat May 19, 2012 7:39 pm
Posts: 20
In which case is there anythig for 2.5?.
I have a login menu button. I cant see how to create a logout button.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 40 posts ]  Go to page 1, 2  Next



Who is online

Users browsing this forum: No registered users and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group