I create a module for automatically vote after comment. I use votingapi module for check and storage data, but results don’t register to content (don’t storage for every comment).
Example of code:

// it’s form validation for insert vote
function tcomment_vote($form, &$form_state, $nid) {
$clicked = $form_state['clicked_button']['#value'];
switch ($clicked) {
   
case 'yes':
 $votes[] = array(
     'content_type' => 'comment',
     'content_id' => $cid, 'value_type' => 'points',
     'value' => 1,
 );
 break;
    
case 'no':
 $votes[] = array(
    'content_type' => 'comment',
    'content_id' => $cid,
    'value_type' => 'points',
    'value' => -1,
 );
 break;
}

votingapi_set_votes($votes);
     $criteria = array(
      'content_type' => 'comment',
      'content_id' => $cid,
       'value_type' => 'points',
   );
 }

// check results (after hook form)

function tcomment_select_votes() {
$criteria = array(
   'content_type' => 'comment',
   'content_id' => $cid,
   'value_type' => 'points',
);

$results = (int)votingapi_select_single_result_value($criteria);
drupal_set_message('RESULT'   . $results);
}
// Only last result had here, one for every comment

Please, help, what I wrong?

Comments

legolasbo’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

Drupal 6 is no longer supported. Closing old issues to clean up the issue queue.

Please reopen and update this issue if this is still an issue in the D7 or D8 version.