I want to know if there is a way for me to get a user's points at a particular time. There is a function userpoints_get_current_points that will get me my points as of today.

I would love to be able to send in a date and find the max points that I had at that time.

Comments

berdir’s picture

Status: Active » Fixed

There is no API function, but you might be able to calculate it with an SQL query based on the transactions table.

Basically, you need to load all transactions older than X, optionally of a specific category of a given user and then SUM() the points.

Something like this

$time = mktime(0, 0, 0, 12, 13, 2010);
$points = db_query('SELECT SUM(points) FROM {userpoints_txn} WHERE uid = %d AND time_stamp < %d', 1, $time);
socialnicheguru’s picture

how can I add in the category?

berdir’s picture

Add ' AND tid = %d' to the query and your category term id as an argument after $time.

berdir’s picture

Oh, and please document this somewhere below http://drupal.org/documentation/modules/userpoints as a How-To page, thanks!

Status: Fixed » Closed (fixed)

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