I created a module and I need to use the user name of the user's profile being viewed.

How do I call/get it?

2 Answers 2


You can load a user object like this :

$current_user = menu_get_object('user', 1);
$username = $current_user->name;

Reference of menu_get_object function.


If it's the user that's currently visiting your website that your looking to display then this code can be used.

 global $user;
 print $user->name; 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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