1

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.

0

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? – Kretess Jun 28 '14 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 using dpm() function of Devel module. Then you can modify it as per your need. – wolverine Jun 28 '14 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. – Kretess Jun 28 '14 at 21:48
  • @Kretess updated the answer – wolverine Jun 29 '14 at 5:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.