Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By cgweb on
Hey,
I need to be able to display the currently logged in username on my clients website (http://www.rdl101.com). You will see when you go to the site there is a dashboard type bar at the top, that says "Hey , welcome to RDL101.COM". I need the username to be displayed just after the Hey.
Thanks to anyone who can come up with a solution in advanced, I've tried using the print $user->name
but that doesn't show anything.
Comments
Hi Try this global
Hi
Try this
global $user;
$name = $user->name;
Cheers
Krishna
Thanks but that doesnt work
Thanks but that doesnt work either, but could you expand..
i put
global $user; $name = $user->name;
where i wanted it.. is that right?HI You want to concatenate
HI
You want to concatenate '$name' with the code like
"Hey ".$name." Welcome ..."
Regards
Krishna
Again, thanks but No luck :(
Again, thanks but No luck :(
You are on the right track.
You are on the right track.
Stick <? global $user; ?> somewhere at the top.
Now use
print $user->name
where ever you want to put the user name.THANK YOU! That works =D
THANK YOU! That works =D
Thank you! :-)
Thank you! :-)
How do i display username?
Hello,
is that still in Drupal 9 the solution? Thank you!
Stick <? global $user; ?> somewhere at the top.
Now use print $user->name where ever you want to put the user name.
I'm beginner, were is
"
somewhere at the top"?
How can this codeprint $user->name
be used?Follow up question
Hello, I have a similar problem. I need to display the user First name and last name instead of the username. How can I do this???
I am assuming you are using
I am assuming you are using the profile module with fields for first name and last name? Have a look at the documentation on customizing the user profile layout. It should tell you how to display your 2 custom fields.
First and last name
Hello,
I am actually using the LDAP authentication module to authenticate to Novell. I looked at the documentation but still can't figure out how to display this info from LDAP. Thanks for the help, please let me know if you need more info.
I've never used the LDAP
I've never used the LDAP module so you are probably better off posting it the modules' support requests. I imagine it shouldn't be difficult so long as the firstname/lastname are in a table to retrieve based on the uid which you will have once the user logs in.
Found solution.
I found a way to display fname and lname from ldap. Please post if anybody needs solution.
Yes, please do post your solution
Yes, I am interested in displaying the fname and lname from ldap. I've been reading a thread on mapping profile fields to ldap, but have not had any success to date. Thanks!
Well, if you found the
Well, if you found the solution, all of us need it. Just post it, b'coz any day, any time, any one will need it.
:)
Beautifulmind
Know more
Regards.
🪷 Beautifulmind
Thanks for this answer! I
Thanks for this answer!
I was looking for this :)
_________________
Owner of Diets Wonder - Wondering what kind of diets out there works!