Community & Support

How to get username of current user viewing page?

How can I retrieve the username of the current user viewing a page, either using php or html..?

Comments

Hi, You can print the

Hi,

You can print the username as follows:

<?php
print_r
($user->name);
?>

I guess this will help.

You will need to initialize

You will need to initialize $user in instances.

<?php
global $user;
print_r($user->name);
?>

-Craig Jackson
-Web Developer

-Craig Jackson
-Web Developer

perfect, thank you both very

perfect, thank you both very much.

Excuse me for 'hijacking'

Excuse me for 'hijacking' post, but I have similar issue.

As an admin I'm editing nodes, and I want leave my username (and perhaps editing date too), but using tips from above I'm getting username of current user instead. Any thoughts?