In a recent support request, someone asked how to display the user's points below the user picture (avatar).
This article answers this question.
First, in your theme directory, find the file called template.php. If one does not exist, create it, and make sure it starts with the <?php tag.
Then add this function in it.
Go to the setting, and enable user pictures.
Now, below each user's picture, there should be the number of points that this user has earned so far.
function phptemplate_user_picture($account) {
if (variable_get('user_pictures', 0)) {
if ($account->picture && file_exists($account->picture)) {
$picture = file_create_url($account->picture);
}
else if (variable_get('user_picture_default', '')) {
$picture = variable_get('user_picture_default', '');
}
if (isset($picture)) {
$alt = t("@user's picture", array('@user' => $account->name ?
$account->name : variable_get('anonymous', t('Anonymous'))));
$picture = theme('image', $picture, $alt, $alt, '', FALSE);
if (!empty($account->uid) && user_access('access user profiles')) {
$picture = l($picture, "user/$account->uid",
array('title' => t('View user profile.')), NULL, NULL, FALSE, TRUE);
$picture .= "<div>" .
userpoints_get_current_points($account->uid) . "</div>";
}
return "<div class=\"picture\">$picture</div>";
}
}
}
And there you have it.
Comments
Visitor (not verified)
I believe that person may
Tue, 2007/02/13 - 09:27I believe that person may have been me. Thanks for the code.
Visitor (not verified)
Awesome post - interesting
Thu, 2007/02/15 - 15:23Awesome post - interesting stuff and great looking code.
Visitor (not verified)
great looking code, thanks.
Thu, 2007/02/15 - 15:25great looking code, thanks.
Visitor (not verified)
how do I then call that full image/points unit?
Thu, 2007/05/17 - 16:05Very cool.
How do I call that full image+points unit and have it show up anywhere in my page.tpl.php file? What's the code that will call out for it that I can insert into my template?
Visitor (not verified)
This code doesn't seem to
Fri, 2009/02/27 - 17:34This code doesn't seem to work for me.
I even added the code in template.php
Why is it not working?