Home Blog Tips & Tutorials Changing a Login Menu Link to Logout

Changing a Login Menu Link to Logout

(10 votes, average 3.30 out of 5)

If you use the User > Login > Default Login Layout (Figure 1) link in any of your Joomla menus, you've probably noticed a couple of limitations associated with it. One limitation is that the name of the link doesn't change, or rather, there is not an option to change the text for users who have successfully logged into the site.

Default Login Layout

I have seen the question: "How do I change my 'Login' menu link to read 'Logout'?" asked numerous times and in various ways in forums and on blogs. Well, despite this not being an option in the Joomla core, there is a relatively simple solution using a third party extension called MetaMod. If you don't already have MetaMod installed, you'll need to download and install it before completing the steps that follow. I'll be using a default Joomla installation for the example, though the concepts apply to any Joomla installation and you should be able to translate from one to another without much difficulty.

Step 1: Create a Joomla 'Login' Menu Item

To start, create a link called "Login" on the "Main Menu" in a default Joomla installation. If you don't know how to do this, then tracking down a more basic Joomla tutorial on creating menu items would make things easier. Remember to publish the menu item.

When you're done, you should have something that looks like Figure 2 on the front page of your Joomla website.

Login Menu Item

Step 2: Make a copy of the Menu

Next, use the Joomla Menu Manager to make a copy of the menu that contains the 'Login' link. In my case, the name of the menu is: 'Main Menu'.

The new menu will have two fields to fill in, 'New Menu Title' and 'New Module Name' (Figure 3). Use the same text for both fields and choose something that will help you readily identify the menu/module and distinguish it for what it is. For this example, I chose 'Main Menu - Logout'.

Figure 3: The New Menu

Note: On the right side of the Copy Menu screen, you'll notice a list of menu items that will be copied along with the menu. If you do not see your 'Login' menu item, you've done something wrong.

After saving the new menu, you'll want to immediately select it in the Menu Manager to edit one of the fields that Joomla created for you. The field is called 'Unique Name'. It will contain the same text you entered for the other fields. For consistency and to stay true to the tooltip recommendation, you'll want to change it to a name without spaces. It's probably not a bad idea to keep it short and only use lower case characters too. In keeping with my example, I chose 'mainmenu-logout'.

Step 3: Edit the 'Login' Menu Item on the New Menu

While in the Menu Manager, select the icon in the 'Menu Item(s)' column next to 'Main Menu - Logout'. You'll want to select the 'Login' menu item to edit its details. Change the value of the Title' field to 'Logout'.

Step 4: Configure the Menu Modules

After you have made a copy of the menu containing your link, you'll need to edit a few of the settings for each menu module. In the Joomla Module Manager, click on the new module to edit its settings.

Review the following settings and change where necessary:

Details:

  • Show Title: 'No'
  • Enabled: 'Yes'

Menu Assignment: 'None'

Parameters:

  • Module Parameters > Module Class Suffix: Make a note of this, if you have one specified. You will need it later. You can actually remove it here as it will not serve any purpose when we're finished.

For the original 'Main Menu' module, use the same settings. You'll probably want to change the title of this module too for consistency. I'll change my to 'Main Menu - Login'.

Step 5: Configure the 'MetaMod' Module

Here's where the magic happens. If you haven't used MetaMod before, it's one of those invaluable third party extensions that every Joomla site should have installed (no we don't know the developer and he didn't pay us to say that).

Using the Joomla Module Manager, locate the 'MetaMod' module and click on it to edit its settings. If you just installed MetaMod, there should be an instance that is unpublished. If you had it installed previously and are using it for something else, simply select 'New' in the Menu Manager to create a new instance.

Review the following settings and change where necessary:

Details:

  • Title: 'Main Menu'
  • Show Title: 'Yes'
  • Enabled: 'Yes'
  • Position:
  • Access Level: 'Public' (otherwise there's no point in displaying a login link)

Menu Assignment: 'All' (or on whichever particular pages you want it to appear)

Figure 4: The MetaMod codeAfter filling in the basic information, look at the Parameters > Module Parameters section on the right side of the page. If your original menu had a Module Class Suffix, you'll want to fill that in at the top. Then, about half way down the page, in the 'PHP' text box, type in the code as depicted in Figure 4, replacing my module ID numbers with those that correspond with your Joomla site.

Comments (7)
Thanks
7 Monday, 17 May 2010 08:57
Dana
Great tutorial, thanks!

After installing Metamod, my user menu with logout option "magically" appeared - no complaints from me :-).

I do, however, would like to change the wordings on the logout screen from "You are currently logged in to the private area of this site" and take out the image. How'd I do that? Thanks so much for your help!
Hooray for your help.
6 Friday, 19 February 2010 11:52
Simeon Rice
Thanks man great info.
MM_NOT_LOGGED_IN didn't work.. but this did.
5 Wednesday, 30 September 2009 06:52
Sean
Hi.

I've tried this solution, but Metamod didn't recognize MM_NOT_LOGGED_IN ... maybe that has to do with me having an old version of Metamod... (currently their site is down, so I can't download a newer version).

But I got it working with this query:
if ($user->name == "") return ..;
else return ..;


Thanks for the input!

Sean.
Great tutorial!
4 Monday, 07 September 2009 21:01
Stephen Brandon
I'm the developer and no, I didn't pay for the plug! Thanks for the great tutorial and kind comments though.

I just wanted to mention to you and your users that there's a new support site for MetaMod: http://www.metamodpro.com/ that finally has all the support info properly organised, including a forum.

Also released is a new companion to MetaMod - MetaMod Pro. This is a plugin that solves the 2 most requested issues with MetaMod:

1 - when MetaMod Pro is installed, modules included by MetaMod no longer get wrapped inside the MetaMod module. Thus there's no extra HTML to mess with the CSS of your template. When you include modules, they just appear exactly where they should with no HTML surrounding them.

2 - when MetaMod Pro is installed, and a MetaMod does not include any other modules and produces no output itself, the MetaMod now *completely* disappears. It's not even counted by the template's countModules() function, so templates no longer reserve space for an otherwise-empty MetaMod. If you've ever had this issue, you'll understand what a big deal this is!

MetaMod Pro sells for $19US, but you can get $5 discount until Friday 11 Sept with this coupon: (enter it at checkout)

JOOMLAFARE

Thanks for your work guys,
Stephen Brandon
MetaMod author
Request for translate & include in spanish website
3 Tuesday, 01 September 2009 16:06
Ignacio Iglesias
Hello.

Great tutorial.

I've translated to spanish, and I would like to ask your permission to include it in my spanish joomla website, of course with your original reference and link here. You can see it in http://mundojoomla.org/index.php?option=com_content&view=article&id=136&Itemid=222. (Note that, although more or less advanced, the website isn't yet finished, so I haven't yet released it.)
excellent work
2 Friday, 14 August 2009 15:21
Mark
excellent work, thanks for this tutorial. Metamod rocks!
Thanks
1 Friday, 24 July 2009 10:01
Allard
Hi, Perfect tutorial. Just wanted to thank you for this great help. I am using Joomla just a few days and this hint worked instantly. Regards, Allard

Add your comment

Your name:
Your email:
Subject:
Comment:
  The word for verification. Lowercase letters only with no spaces.
Word verification:

E-mail Updates

Subscribe to our free mailing list for news and updates.



Receive HTML?

Your privacy is important. We will never share your information.