Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter

In this Discussion

[Voting Addon] Bug: Can vote more then once on post (Is this being maintained?)*

This discussion is related to the Voting addon.
Any "answer/thread" we call it post/topic etc

Anyways it allows duplicate, but on discussions view like on here, you can only vote it once.

Sorry if this is duplicate

Comments

  • I agree with you.
    Also when I clicked voting button even in this forum it resets voting counts...
  • I have the same problem. Voting seems to work alright in this discussion but not in the downloadable addon.
  • Looking at the next post down you need to make sure your not using an admin account.
  • yes, i have got same problem with voting. admin can vote up limitless, and normal accounts can reset the vote count.
    Silvestr92
  • sahotataransahotataran Rare Visitor ✭✭
    seems like this problem still continues with me. anyone found any solutions to this?

    Theme Charcha for great desktop and mobile experience! - drop me a message :)

  • I have several similar issues as well - I understand admins versus users but still think it should only be once. Some people can vote once, some several times, some endless. I would really love to get a fix for this. Does someones have one? Are there any other voting plugins? Thx in advance.

  • I had to change some things in the voting plugin but this worked for me. It makes it so that it only allows users to vote on comments once (+1 or -1) without having that crazy bug where it resets the voting count when logged in as a regular user(admins can still vote unlimited). Just replace the content in class.voting.plugin.php around 249-268 with this:

    $CommentID = GetValue(0, $Sender->RequestArgs, 0);
          $VoteType = GetValue(1, $Sender->RequestArgs);
          $TransientKey = GetValue(2, $Sender->RequestArgs);
          $Session = Gdn::Session();
          $OriginalScore = $Object->Score;
          $FinalVote = 0;
          $Total = 0;
          if ($Session->IsValid() && $Session->ValidateTransientKey($TransientKey) && $CommentID > 0) {
             $CommentModel = new CommentModel();
             $OldUserVote = $CommentModel->GetUserScore($CommentID, $Session->UserID);
             $NewUserVote = $VoteType == 'voteup' ? 1 : -1; //if voteup then $NewUserVote = 1 else -1
             $FinalVote = intval($OldUserVote) + intval($NewUserVote);
             // Allow admins to vote unlimited.
             $AllowVote = $Session->CheckPermission('Garden.Moderation.Manage');
             // Only allow users to vote up or down by 1.
             if (!$AllowVote && ($FinalVote > -2 && $FinalVote < 2)){
                $AllowVote = true;
             }else {
                $AllowVote = false;
             }
    
             if ($AllowVote){
                $Total = $CommentModel->SetUserScore($CommentID, $Session->UserID, $FinalVote);
             }else {
                $FinalFinalVote = $OriginalScore + $OldUserVote;
                $Total = $CommentModel->SetUserScore($CommentID, $Session->UserID, $FinalFinalVote);
             }
    
    matt
  • I tried doing this, but it prevents my admin account from making and votes at all on posts...

    I'm gonna disable this plugin until this is sorted out, otherwise I really like it! :/

  • @A_Hashmi said: I tried doing this, but it prevents my admin account from making and votes at all on posts...

    I'm gonna disable this plugin until this is sorted out, otherwise I really like it! :/

    @A_Hashmi Did you make sure that you have the checkbox checked under Garden>Moderation>Manage in the Roles & Permissions section of the Dashboard?

    That's what line 14 in the above code is for to allow admins or whatever role with that checkbox checked to be able to vote infinite amount of times.

Sign In or Register to comment.