Take action on first vote only I'm using Drupal 7 with the FiveStar module to let users vote on a certain node type. When the user votes, I have a workflow rule that grants them some points to reward them for casting their vote.

The problem I'm running into is that if the user votes more than once on a given node, they are granted points again, each time they vote. There is currently no filter to check that they have already voted before awarding the points.

I could use some help building a workflow rule filter that checks to make sure the user has not already voted on the particular node.

Conceptually I would like to query the votingapi table for any records with the given node ID and given user ID and pass only if zero records are returned. But not sure how to do this in Drupal. Trying to avoid hard-coding a query too. 

Thanks
BH
No need to hardcode a query. The voting api module provides some helper function for this.

The function you need is votingapi_select_votes($criteria = array(), $limit = 0)

The $criteria parameter takes a decent amount of options.

Here are the options:

$criteria['vote_id']  (If this is set, all other keys are skipped)
$criteria['entity_id']
$criteria['entity_type']
$criteria['value_type']
$criteria['tag']
$criteria['uid']
$criteria['vote_source']
$criteria['timestamp']   (If this is set, records with timestamps
                          GREATER THAN the set value will be selected.)


In your case you really want to pass in the 'entity_id', 'entity_type' and 'uid' to check if the user has voted in that particular content item before awarding him points.

This is the same way we prevent a user from voting multiple times in the same item with Fivestar.

Hope this helps.