3

I want to put condition when userpoints>=30, then user is able to vote.

For this, I did following steps-

  • ON event- "User votes on a node" the condition selected is "Compare current Userpoints" and in the condition part put ">=30".

I am using following modules: Rules, User Points and Vote Up/Down.

1
  • You could disable voting for normal registered users and create a new user role which allows voting. If one is awarded User Points, you can check his/her total amount of User Points with Rules and grant that user the new role you created if the total is larger than 30.
    – Jeroen
    Jun 27, 2016 at 9:35

2 Answers 2

2

You should try to implement the hook form alter Drupal API: hook_form_alter

Within the hook_form_alter you can validate, if the current user has more then 30 Points and disable the voting widget if the value is below 30.

0

There seems to be a contradiction in what you are asking for:

  • '... ON event- "User votes on a node" ...': if that (Rules) Event has been triggered, then the vote has already been completed.
  • 'If ... then user is able to vote ...': if the condition is NOT satisfied, the user should NOT be able to vote.

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

  • Grant some permission when a user's amount of user points reaches 30, 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 30 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 30 (and revoke that access if it is below 30). If you'd also use the Conditional Rules module, you can perform both types of Rules Actions (grant and revoke) in a single rule.

Your Answer

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

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