0

I manually deleted a couple of User Point transactions in my database's table userpoints_txn. This results in inaccurate current User Points in the table userpoints_total. Clearing caches or running cron doesn't resolve this problem.

Is there a way to recalculate the current total User Points for all users?

1

You should have used the Userpoints admin UI or its API (e.g. userpoints_userpointsapi()) to make changes in the records. That way you can make point adjustments without the problem of database integrity that you've introduced. If possible, I'd restore the DB rows and adjust the point records with the UI/APi.

In absence of that being a possibility, you can see that _userpoints_update_cache(), the function used for maintaining updated userpoints/userpoints_total tables, requires those tables to always be consistent, as they are referenced when transactions are added/updated/removed. Thus, the userpoints code won't be much help here.

You'll have to do an aggregate SQL query on the userpoints_txn table for each impacted user to determine their updated score and use that to update the userpoints/userpoints_total tables accordingly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.