Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Show User Name When Logged In
Show User Name When Logged In
Re: Show User Name When Logged In
Hi,
you can do this easily using the PHP functionality of MetaMod, rather than its ability to include other modules.
So this would do the trick:
if ($user->id > 0) echo "<b>Welcome " . htmlentities($user->name) . "</b>";
You don't need the Pro version, BUT you may find that with the free version, when no user is logged in, a sort of blank module is displayed. You can get around that by setting the MetaMod to only display for registered users. Or, the Pro version would have the same effect. But there's no real need for the Pro version in this case.
Best regards,
Stephen
Re: Show User Name When Logged In
Wow! Thank you very much for that.
I'm not entirely sure how to set it up though. I was able to see the module #135 which has the login link using the code below, but how do I see #138 module when logged in?
I created another MetaMod (#138) and add the code you provided in the PHP area but I don't see anything.
if (MM_LOGGED_IN) return 138;
else return 135;
Thanks!!
Re: Show User Name When Logged In
May I please ask for some further help.
I was trying to add a link on the "Logout" text but it's not working. This is what I have.
if ($user->id > 0) echo "<b>Welcome, " . htmlentities($user->name) . "</b> | <a href="">Logout</a>";
What am I doing wrong? Thanks!!
Re: Show User Name When Logged In
Hi,
you'll need to find what the logout link is for your site, then put that into the <a ...> link. To find the logout link, I would suggest making a menu item for viewing the user profile or login (I forget which). Then it will have a URL and you can see that URL from the front-end. Then move the menu item to a menu that doesn't get displayed on screen, if you like.
So the eventual code might be like this depending on your SEF URLs:
if ($user->id > 0) echo "<b>Welcome, " . htmlentities($user->name) . "</b> | <a href="/logout">Logout</a>";
Best regards,
Stephen
- Index
- » MetaMod
- » MetaMod General Support
- » Show User Name When Logged In
Board Info
- Board Stats:
- Total Topics:
- 1698
- Total Polls:
- 6
- Total Posts:
- 5944
- Dormant:
- User Info:
- Total Users:
- 5595
- Newest User:
- gary099231
- Members Online:
- 0
- Guests Online:
- 145
- Online:
- There are no members online
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked