I need delete a vote after user votes on a node.
My rule is:
Event: User votes on a Node
Condition: check some parameters (php evaluation).
Action:
db_query ('DELETE FROM {votingapi_vote} WHERE vote_id = :vote_id', array( ':vote_id' => $vote['vote_id'] ));
votingapi_recalculate_results($vote['entity_type'], $vote['entity_id']);
And it works fine, except this Notice:
Undefined variable: vote_results in function voting_rules_votingapi_results() (row 48 in file \sites\all\modules\voting_rules\voting_rules.module).
Please, help me, if have a time
Comments
Comment #1
hlopes commentedThe same error appeared in my site, when deleting a vote ( i'm assuming it only happens if it is the only vote the node has )
That means that for some reason, the $vote_results variable is not set ( hence my guess )
Adding
Before the troublesome line solved my issue.
Comment #2
istryker commentedWhy are you doing a direct db query. Just call
votingapi_delete_votes(). You will still need to call recalculate results.This is not the way to do things. It may be the only way of doing things right now though.
Closing issue. See #1882116: Need Action to delete or reset the vote
Comment #3
isimgt commentedThanks HLopes, #1 working for my..
Comment #4
Anonymous (not verified) commentedI was having this same problem too, when a user reverses a vote so that the content has no votes on it anymore. I added the fix from #1, and I don't get this error anymore. I'm surprised this hasn't been added to the code, that solution was provided 3 years ago?