Last updated 26 August 2009. Created on 15 June 2006.
Edited by bekasu, Michelle, greggles. Log in to edit this page.

PLEASE NOTE! These snippets are user submitted. It is impossible to check them all, so please use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.


This php snippet displays the number of points for the user using the userpoints.module.


  • For use in your user profile page override (or anywhere else you want to display user points)
  • Using a text editor like NOTEPAD.EXE or an equivalent, copy and paste the code into your user_profile.tpl.php file
  • Tested and works with Drupal 4.7 and 5.x
  • Change the div class names or the prefix text to suit.

You can directly query the database:

<div class="fields">
<p><?php  print t('Points:').db_result(db_query('SELECT points FROM {userpoints} WHERE uid = %d', $user->uid));?></p>

Or use this function call which does the query for you:

print userpoints_get_current_points($user->uid);

Remember if you use this snippit in other places that you need to be sure the $user object is set to who you want first so you're passing in the correct ID.

The above code for "userpoints_get_current_points" might print the userpoints for the current logged in user (user who is viewing the profile) and not the "user profile's owner".

Modifying this

print userpoints_get_current_points($account->uid);

it prints the points for the user profile's owner.

Looking for support? Visit the forums, or join #drupal-support in IRC.