I'm working on a RPG website. Users are awarded userpoints (named XP for the need of the "game") depending on their actions.

I want to make a level system based on these userpoints. I already made a table using Drupal Data, which stores values for each level (level number, minimum XP, maximum XP, and some ratios to apply when a user is earning points).

My question is : How can I refer to this table to check a user level (and all the values attached) depending on the user's amount of XP?

I tried with Rules, but no success.

  • if your custom table has a column uid you can reference with global $user?!
    – Akko
    Oct 3, 2014 at 21:24
  • My custom table doesn't have a custom uid. This table is only used to store the level values. I wish I could do something like this : when a user gain or lose XP, then check new XP value, then compare to minXP and maxXP values in the table (minXP <= XP <= maxXP), then fill user profile special fields with values taken from the relevant row in the table. The problem is that I'm not a developper at all, so I have no idea on how to achieve this. Oct 4, 2014 at 8:43

1 Answer 1


Give it some thought to replace that table you made with:

  1. a new content type (eg called "XP") and
  2. with custom fields as in your question, such as:

    • level number.
    • minimum XP.
    • maximum XP.
    • some ratios.

That way you could create 1 node for each row in your table, with field values matching the values in those table rows. If appropriate, use the Feeds module to automatically create 1 node for each row in your table.

After you'd have created such nodes, you could use them in combination with the modules you're already using / considering, such as User Points and Rules.

To implement that "level system" (as in your question), you can probably use the Goals module (disclosure: I'm the maintainer of it). If you're not familar with this module, have a look at "How to implement gamification in a Drupal site and award incentives?".

Bonus tip: since you're thinking of using User Points and Rules already, you may also want to look at the answer to "How to access current amount of earned userpoints in a Rules Condition?" (pretty sure you'll need something like that also).

PS: All this only requires site builder skills (no need for any custom coding).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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