Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Show User Name When Logged In

Show User Name When Logged In

I would like to display the user's name when they log in something like this:
Welcome Melanie!

How do I do that please?  Do I need the pro version for this?

Thanks in advance!!

MyWorld
Beginner Modder
ranks
useravatar
Offline
14 Posts
Administrator has disabled public posting

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

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3314 Posts
User info in posts
Administrator has disabled public posting

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!!

MyWorld
Beginner Modder
ranks
useravatar
Offline
14 Posts
Administrator has disabled public posting

Re: Show User Name When Logged In

Ooops!!  Nevermind it worked.  I got mixed up with the module IDs.

Thanks!!

MyWorld
Beginner Modder
ranks
useravatar
Offline
14 Posts
Administrator has disabled public posting

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!!

MyWorld
Beginner Modder
ranks
useravatar
Offline
14 Posts
Administrator has disabled public posting

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

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3314 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1691
Total Polls:
6
Total Posts:
5912
Total Posts Today:
6
User Info:
 
Total Users:
11515
Newest User:
velis415
Members Online:
0
Guests Online:
257

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