Is there a module with a functionality to delete votes using the voting api? If not, how do I implement a button that erases all votes? Or is it easier if I just empty the MYSQL table?
1 Answer
The voting api defines some drush commands:
drush generate-votes <entity_type> <vote_type>
drush votingapi-recalculate <entity_type>
drush votingapi-flush <entity_type>
if you don't use drush, you can run the code from the function that the module uses on devel php or similar
<?php
$entity_type = "name_of_the_entity";
$cache = db_delete('votingapi_cache');
$votes = db_delete('votingapi_vote');
if (!empty($entity_type)) {
$cache->condition('entity_type', $entity_type);
$votes->condition('entity_type', $entity_type);
}
if (!empty($entity_id)) {
$cache->condition('entity_id', $entity_id);
$votes->condition('entity_id', $entity_id);
}
$cache->execute();
$votes->execute();
$vote
, though, if I only know the entity id of the object that has been voted on?