11

I have a website using Joomla 3.5 and I currently have a 'Login' main menu item. Once a User logs in, there are some sub-menu items that appear under the 'Login' menu item.

What I want to do is to change the menu item name from 'Login' to 'Logout' and point it to another page so they can actually log out.

1
  • To all German administrators: The translation of Logout is 'Anmelden' instead of 'Abmelden'. When I previously looked at this feature I omitted to read the small print:-)
    – user8230
    Apr 13, 2016 at 8:38

4 Answers 4

11

The Good Folks at OSTraining just published this nice Tutorial:

Step #1. Create the Login link

  • Go to Menus > your menu > Add New Menu Item

Create the Login link

  • Enter a Menu Title.
  • Select the Menu Item Type.

enter image description here

  • Choose Users > Login Form.

enter image description here

  • 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 to create it.

enter image description here

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.

enter image description here

  • 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.

enter image description here

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

enter image description here

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 Joomla's Access Control Levels.

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


As always, thanx to OSTraining for best Joomla Tutorials out there.

3

In Joomla! 3.5 we have a new menu item type called Logout in Users section,
create a new menu item and select this new option, see the screenshot:

enter image description here

Regards.

2
  • Hi Alex, I have no problems creating a Log Out button and making that work, the issue I am having is I want the "LOGIN" menu item to disappear so that I can have another menu item in its place with a "LOGOUT" option within it. The website in question is www.lsl.global
    – Sam Potts
    Apr 7, 2016 at 3:53
  • Hi Alex, I cleared my cache after making some changes to the User Access Levels and it is working now.
    – Sam Potts
    Apr 7, 2016 at 3:59
2

I had to do the same thing on one of my sites.

Firstly, you should create a Template Override for the mod_login module

Once done, you should have the following file:

ROOT/templates/YOUR_TEMPLATE/html/mod_login/default_logout.php

Note: The path may be slightly different depending on the template's framework.


Then, Open the file mentioned above and add the following code

$doc = JFactory::getDocument();
$doc->addScriptDeclaration('

    jQuery(document).ready(function($){

        $("#nav").find(".item-222 a").empty().text("Logout");

    });

');

You will of course need to change #nav to your menu wrapped selector and .item-222 a to the menu item selector.

If you provide a link to your site, I can give you the exact code used above, but until then, this is all I can provide.

Hope this helps

2

I made changes to the User Access Levels but these didnt appear to be working, I have since cleared my cache and now the website appears to be working how I wanted to.

FOR USER ACCESS LEVELS:

  1. PUBLIC: leave all options unchecked
  2. GUEST: checked Guest only
  3. REGISTERED: checked Manager, Registered User and Super User

FOR THE MENU ITEMS:

  1. MAIN MENU: User Access Level set to 'Public' by default
  2. LOGIN: Changed User Access Level to 'Guest'
  3. ADMIN with Sub-Menu Items: Changed all User Access Levels to 'Registered', this includes my "logout" button.

Now when I login, the menu updates correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.