I have installed VotingApi with Vote Up/Down, also have my own module which implements user exp and levels. I want the voted to be more powerful if the user has greater level. I search through Vote Up/Down files but didnt find a file inserting the vote to databse, so I could change it depending on my needs.
1 Answer
The vote will be casted by calling the Voting api function votingapi_set_votes()
. But if you want to change the votes before sending it to Voting api
there is hook for this called hook_vud_votes(&$votes)
which you can use.
Update:
The api file mentions a hook called hook_vud_votes(&$votes)
to alter the vote but in their code they are invoking the hook using drupal_alter()
, so the right hook to implement is hook_vud_votes_alter(&$votes)
, I think it is mistake in their api doc.
-
And the &$votes is an array like in drupalcontrib.org/api/drupal/… but only with one record - the current vote?– KretessJun 28, 2014 at 16:44
-
The function accepts an array of votes, a single vote can also be passed. Implement
hook_vud_votes()
and check the$votes
array structure usingdpm()
function of Devel module. Then you can modify it as per your need.– msmaniJun 28, 2014 at 16:58 -
hook_vud_votes() seems to do not work. Tried by dpm, than also
function reputation_system_vud_votes(&$votes) { watchdog('reputation_system','test'); }
but nothing appears in log.– KretessJun 28, 2014 at 21:48 -