I'm interested in theming user profile page so that I can insert some code for the user viewing their own page. Any advise on how to check to see if user viewing page is same as the profile being viewed?

I was thinking it could be as simple as: if ([uid of logged in user] == $user->uid):

Is there a variable like that that I can use?

Thanks in advance

Comments

michelle’s picture

You can get the logged in user with global $user; which will make the $user variable come in scope.

You can get the user of the profile by looking at the URL:

$account_id = arg(1);
$account = user_load(array('uid' => $account_id));

Michelle

jibbajabba’s picture

Excellent. Thanks, Michelle

jjohn’s picture

hi!

how can i print in a block the username of the profile being viewed?
can this be done using views module?
or do i need a code for the body?

please help me with this...

thanks

avpaderno’s picture

Using the code provided in the previous comment, simply use print $account->name;.

jjohn’s picture

hi!

it works!

thanks for the very prompt reply
to my silly question... =)

+++
honestly, i don't know how to do php coding.
but this cms platform makes me confident to make sites.
great and uncomparable support!

drupal rocks!