Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 UTC on 18 March 2024, to get $100 off your ticket.
function plus1_vote doesn`t pass arg vote_source to voteAPI.
Problem: If anonymous user do "vote undo" and ip address of anonymous and registred user are equals then votes of this node will reset.
you should pass vote_source to voteAPI:
'vote_source' => $user->uid ? $user->uid : ip_address(),
all code:
function plus1_vote($entity_type, $entity_id, $tag = 'plus1_node_vote') {
global $user;
if (!drupal_valid_token($_GET['token'], $entity_id, $skip_anonymous = TRUE)) {
watchdog('plus1', 'Voting form error: Invalid token.');
return drupal_access_denied();
}
$voted = plus1_get_votes($entity_type, $entity_id, $user->uid, $tag);
//print_r( $voted );
// If the voter has not already voted.
if (!$voted) {
$votes[] = array(
'entity_type' => $entity_type,
'entity_id' => $entity_id,
'value_type' => 'points',
'value' => 1,
'tag' => $tag ? $tag : 'plus1_' . $entity_type . '_vote',
'vote_source' => $user->uid ? $user->uid : ip_address(),
);
Comment | File | Size | Author |
---|---|---|---|
#1 | 1246254-0.patch | 452 bytes | rogical |
Comments
Comment #1
rogical CreditAttribution: rogical commentedI created a patch for this
Comment #2
shopobdii CreditAttribution: shopobdii commentedIt is very useful, thanks for your sharing! I am looking forward to your update.
Comment #3
rogical CreditAttribution: rogical commentedCommitted.
Comment #4
NancyDruShaun, when you fix an issue, mark it "fixed" so that it stays visible for another two weeks.
Comment #5
rogical CreditAttribution: rogical commentedOkay, got it.