0

Principle: limit user's votes to 10.

Modules used: Voting API, Rate (or maybe Plus1)

Context: Users can vote on projects with 10 possible votes to distribut on all projects, by 1 to 10 votes on each project of their choices, up to a total of 10 votes.

When a user has distributed 10 votes, he loses the permission to vote. To swith the permission with rules, I create a role "Voter". All users have the role by default.

At that point, I have this:
- Event : content is viewed (of type project)
- Condition : site:current-user:uid equals vote:uid
//And now I'd like to say something like "AND vote:uid appears 10 times in the 'votingapi_votes'.'uid' SO
- Action : Add/remove user role to simple AU (without vote permission)

So how to compare with a rule condition vote:uid to 10 instances?

1 Answer 1

1

In the scenario you describe, a simple solution could be to create a profile field to store the number of votes per user. This field will be:

  • set to 0 as a default value
  • incremented when the user votes (you can use Rules for that, there is an action called "Set a data value")
  • compared with your defined maximum (ex: 10) in Rules, so that when the user reaches 10, something is triggered (ex: Remove user role: "Voting User")

You can then set the voting API permissions to this role ("Voting User"), and use it as a display condition to hide the voting buttons (Plus 1 or Rate).

Hope it helps! Cheers

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.