Hi,

I am looking for a condition to check if the current user has already voted on the node.
I would like to trigger the action only if the vote is a *new* vote.

Can anyone please assist?

Thank you very much!

Comments

betoaveiga’s picture

Probably you'll have to use some PHP condition using the voting API... I'll try this module soon, I need the same functionality, perhaps I could help soon :)

heydemo’s picture

Status: Active » Postponed

Problem is that VotingAPI does not keep track of this info, and we're hooking into the process AFTER the vote has been inserted into the database....so this would require a change to VotingAPI Module to fix.

So there is no way for Voting Rules to know if content has been voted on before.

A possible workaround would be to set a user based flag on the content when a user votes on content i.e. 'User has voted on node', then to add a condition to check that flag.

Taxoman’s picture

Version: 6.x-1.0-alpha1 » 7.x-1.0-alpha1
Priority: Normal » Major

Is this also an issue on D7? (then I assume it would be solved in that branch first now)
This comes quite close to being considered a "bug".

heydemo’s picture

Yes, this applies to Drupal 7. I guess you could consider it a bug...the problem is that Voting API was not written from the perspective of supporting Voting Rules....and I am powerless to fix this problem since it requires changing code in Voting API module. If there is enough interest maybe I can talk to Voting API maintainers to see if we can resolve this issue.

Taxoman’s picture

Hmm, surely Voting API is "here" to provide other modules with what is regarded as important functionality (its an API after all), so it would be a bit strange if the maintainer was unwilling to make such adjustments - IMHO.
If there is not a feature request for this over on that project already, we should make one now.

heydemo’s picture

Ok, I've created an issue in Voting API queue
http://drupal.org/node/1269614

istryker’s picture

Status: Postponed » Needs work

The best solution would be to add an event "pre vote cast", where you can do stuff before the vote happens. Currently this is not possible.

@heydemo, IMO #1269614: Add pre-save or pre-set hook before data is store to database will not solve this problem either, as that is an in code solution, and the rule will only fire after the vote has be casted.

I believe #1880462: Keep track of the previous vote in the database patch to VotingAPI will allow you to be able to create a condition to do this.

The condition would by an if statement. It would be something like:
If the current previous vote is NULL, then this is the first time the vote has be casted; therefore, user has NOT already voted on entity/node. Return FALSE [first time voting]

Remember:
#1 - Rule runs/triggered after the vote has been casted and added/updated to the database (updated = old one delete new one added)

perforator’s picture

Whats the status of this issue? I've patched voting_rules.rules.inc but it seems I don't get the rule working. Can somebody please give step-by-step instructions for creating the rules? I've looked at the screenshot in the various issues but I didn't get it.

My usecase: Vote (thumb-up) on nodes for increasing radioactivity (module).

Thanks