Im trying to get the user stats to display in user profiles using a custom user-profile.tpl.php file. Tried adding stats print $profile['Statistics']; but nothing shows.
In forums and comments it all works perfect, is it possible to show the stats in profiles?

Comments

liam mcdermott’s picture

Component: Documentation » Code
Status: Active » Postponed (maintainer needs more info)

Firstly, just to check, are you trying to use Advanced Forum or Advanced Profile Kit? User Stats has its own way of integrating with them.

If not, use something like the following code:

<p><?php print user_stats_get_stats('post_count', arg(1)); ?></p>

arg(1) gets the uid; however your code may be easier to read if you got the uid from $profile instead. The API docs have some code you can use to see what's stored in $profile: http://api.drupal.org/api/file/modules/user/user-profile.tpl.php/6

Also see the User Stats documentation for a full list of the statistics available and how to use them. Hope this helps. :)

volf’s picture

Thanks that works!
I'm not using advanced forum or profile kit. I recently changed from phpbb based sites to drupal so i have allot to learn still. Trying not to be dependant on to many big modules, instead i use small ones and do as much customising as i can to accomplish something close.

liam mcdermott’s picture

Trying not to be dependant on to many big modules, instead i use small ones and do as much customising as i can to accomplish something close.

I applaud your method, you'll learn a lot more doing things that way. :)

liam mcdermott’s picture

Status: Postponed (maintainer needs more info) » Fixed
Anonymous’s picture

For the post count you can change the visibility of the profile field to public. No code changes required.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.