Man, I feel like an idiot for asking, but here goes...

I simply want to print out the currently logged in user's name on the page. I've tried print $user->name, but that doesn't return anything. I've tried to look through the code to see if I could come across a clue, but alas - I'm clueless.

Can someone fill me in?

Thanks!

Comments

ax’s picture

global $user;
print $user->name;
cj-1’s picture

That worked, thanks! Just curious, is there a list of all variables that can be accessed in the same way? I looked at the get_variable function, but that looks like it only grabs from the variables table in the database (please give me hell if I'm wrong).

Thanks again for the quick reply!

Dries’s picture

And if you want the username to be a link to the user's information page, you can do:

  global $user;
  print format_name($user);