3

I am using Drupal 7 and working on a rating site using Fivestar and Userpoints.

What I want is for a certain amount of points to be deducted from a user when he makes a post, and also points deducted from a user when he votes on a node.

The rating and points deduction works well, but the issue is negative points. I don't want any user's points to go below zero. I need to prevent users from having negative user points on the site.

1
  • Implementing a functionality or a layout seen in a site, for which just a description of the feature, a screenshot, or a site URL is provided is considered off-topic. At least show what you already have, so we can help you with improving that. Commented Mar 9, 2017 at 16:04

1 Answer 1

0

IMO you should only allow voting for users which have at least X user points. Here is a technique to get that to work:

  • Grant some permission when a user's amount of user points reaches X, and take that permission away again if it gets reduced to some amount below that. The obvious permission to be used for this is by using the role which allows voting.
  • Monitor changes in user points for a user, by using the Rules module like so:

    • Use the Rules Event that captures user points being rewarded (whereas such points can be negative also ...).
    • Use the Rules Event (or Rules Action!) as described in How to access current amount of earned userpoints in a Rules Condition? (be aware that there is no out-of-the-box Rules Condition like "does this user have at least X user points"?).
    • Perform a Rules Action to grant access to the role that allows voting, when the user's amount of user points is at least X (and revoke that access if it is below X). If you'd also use the Conditional Rules module, you can perform both types of Rules Actions (grant and revoke) in a single rule.

With that, all that's left is to pick a vaue for ... X!

Note: this approach does not require any PHP coding, so "programming experience" is not required (you only need to be a bit familiar with Rules, for which there are lots of free tutorials available.

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.