login and logout

One of our Pro members was browsing around OSTraining and saw that the menu link "Login" was automatically replaced by "Logout" once someone had logged in.

This task has become even easier, thanks to a new feature in Joomla 3.5.

In this tutorial, I'm going to show you how to create a Login menu item that only appears users that aren't signed in. Once they sign in, they'll get a Logout menu item instead. 

Step #1. Create the Login link

First, let's create the Login.

  • Go to Menus > your menu > Add New Menu Item
How to Set up Login and Logout Links in Joomla
  • Enter a Menu Title.
  • Select the Menu Item Type.
image
  • Choose Users > Login Form.
image
  • Set "Access" to "Guest"
  • Click "Save & New".

Guest access will make it so that it only appears to non-logged-in users. If for some reason your site doesn't have Guest access, you can use this tutorial[1] to create it.

image

Step #2. Create the Logout link

Next, let's create the Logout link.

  • Create a new menu item.
  • Enter a Menu Title.
  • Select the Menu Item Type.
image
  •  Choose Users > Logout.

This feature was added in Joomla 3.5. So if you don't have this option, you'd need to update to Joomla 3.5 or later.

image
  • Switch "Access" to "Registered".
  • Click "Save & Close".
image

Step #3. Test the links

Finally, let's test to make sure we got everything right.

Here are some things to check for:

  • Does the "Login" appear when logged out?
  • Does the "Logout" appear when logged in? Does it appear when logged in with another account of a different access level? If not, you may need to adjust the Access Control. We have a class on that at htJoomla's Access Control Levels[2].

That's all there is to it. Congrats! Joomla 3.5 and higher makes it really easy to set up.


About the author

Nick is the Director of Support at OSTraining and you can find him in almost every area of the site, from answering support requests and account questions to creating tutorials and software.


References

  1. ^ use this tutorial (www.ostraining.com)
  2. ^ htJoomla's Access Control Levels (www.ostraining.com)

Read more

© 2024 Extly, CB - All rights reserved.