This could be a new thread about how to display user picture, user name etc in the custom user profile page.

I had a question about showing the profile fields and got help from nice people but it didn't work out the way you want it to do. You will actually see your own stats when visiting other users profile(user name, picture, profiel fields). In fact I couldn't display anything in a proper way.

Comments

michelle’s picture

I'm not using 6, so I can't offer a lot of help, but here's one tidbit: If you want the user of the profile to use in your code:

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

Michelle

--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.

Chippe’s picture

Thanks

Chippe’s picture

Thanks to WorldFallz the problem is now solved.

Turns out in d6 profile fields moved from $user to $account.

michelle’s picture

You should use always have used $account for the variable to avoid conflict with the global $user variable. This isn't new in D6.

Michelle

--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.

Chippe’s picture

Ohh I see.

I am wondering about your first post:

<?php
$uid = arg(1)
$account = user_load(array('uid' => $uid));
?>

What does it do?

michelle’s picture

The user profile page will have a URL like user/42. Doesn't matter if you alias it. Drupal still sees that as the path. So $uid = arg(1) sets the variable $uid to 42. The next line loads the user object into the variable $account. Between those two, you have everything you need to refer to the user who's profile you are viewing rather than the user who is doing the viewing.

Michelle

--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.

Chippe’s picture

Interesting..

Thank you for explaining, Im impressed.
Let's see if I can figure out how to display users name in a block when viewing their profile.

Edit: I tried with the following code in a block on the profile pages.

<?php global $user; ?> 
<?php
$uid = arg(1)
$account = user_load(array('uid' => $uid));
print account->name;
?>

I get unexpected t_variable on the $account line. I think I need to se an example.

michelle’s picture

My fault. $uid = arg(1) needs a semi colon at the end. I'm forever missing those dang things. Other than that, it looks right.

Michelle

--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.

Chippe’s picture

And Im not skilled enough to understand it :-)

I used "print theme" instead and it works just like I wan't it to do.
Thank you so much!