I am using T3 Framework blank template. In the megamenu I have inserted the login form as a submenu, so it shows up when the user hovers over the menu item.

I would like to change the menu item title (or the text that shows there), depending on if the user is logged in e.g. 'Login' if they are not and 'hi (username)' when they are.

Is this possible, maybe by adding some php in the template, without creating 2 different menu items, one for guest users and another one for registered?

  • Just set the login module permissions to Guest and make another module (hi) and set it's permissions to Registered :)
    – jonboy
    Commented Aug 18, 2015 at 19:17
  • But I cannot assign more than one module to one menu item...
    – dfk_7677
    Commented Aug 18, 2015 at 19:19
  • @johnny_s - but then won't the registered users also be able to see the "guest" login?
    – Lodder
    Commented Aug 18, 2015 at 19:38
  • @Lodder No, unless I am misunderstanding the question (which is very possible!). I did this recently and it worked fine, I'll try write an answer if I get time.
    – jonboy
    Commented Aug 18, 2015 at 19:54
  • @johnny_s - Ahh fair enough. Would like to test your solution as it would save me doing a template override on my sites
    – Lodder
    Commented Aug 18, 2015 at 20:02

2 Answers 2


This is what I did:

Create a Template Override for mod_login

Once done, open the following file:


and add the following:

$doc = JFactory::getDocument();
        $(".menu").find("a.something").empty().text("Hi ' . $user->username .'");
  • Thank you. Overriding and adding the JS did what I wanted. There is just an error in your JS code as text(Hi ' . $user->username . ') should be text("Hi ' . $user->username .'")
    – dfk_7677
    Commented Aug 18, 2015 at 21:50
  • @dfk_7677 - Ahh yes, good spot. Updated
    – Lodder
    Commented Aug 18, 2015 at 22:21

If I am understanding your question you want to hide/change the menu item depending on whether or not a person is logged in or not?

OK this is how I managed to how to hide content from guest users or logged in users.

Create a new 'Guest' group;

  • Create a Guest Group in the User Manager
  • Add a new Guest Viewing Access Level
  • Change the default guest group in the User Manager options

There's a detailed guide here.


  • Find the module you want visible for Guests > Edit > Set the Access to Guest
  • Find the module you want visible for Registered Users > Edit > Set the Access to Registered

This should solve your access level issues.

In order to add the 'Hi {Username}' what I did was use NoNumbers Sourcerer and simply echo the $user->username in the module title.

Sourcerer checks your php code to see if you are referencing any commonly used Joomla objects / variables, and then creates them for you. This means you don't have to create these variables yourself every time.

Perhaps not the cleanest method (compared to @Lodders) however it does work and is easily replicated for other modules etc...

Hope this helps!

  • Thank you for your answer, but as you said @Lodders method is clearer.
    – dfk_7677
    Commented Aug 18, 2015 at 21:46
  • No problem - I agree! :)
    – jonboy
    Commented Aug 19, 2015 at 7:52
  • You got my vote as it's another possible solution, however I'm not a fan of installing a plugin that's nearly 1mb for a small task.
    – Lodder
    Commented Aug 19, 2015 at 10:25

Your Answer

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

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