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
Support for Vanilla Forums Cloud product

In this Discussion

Follow Us


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

edited February 2011 in Questions
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 Developer, Bay Area - CA ✭✭✭
    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.

  • BboyHavocBboyHavoc New
    edited April 2012

    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.

  • peregrineperegrine MVP
    edited November 2013

    @kramer65 said in this discussion in outer space.

    http://vanillaforums.org/discussion/25407/how-to-restrict-users-from-voting-more-than-once-in-the-voting-plugin

    I believe the answer is in this thread.

    2 questions -

    1) did you read all the discussions related to plugin. always a good idea to do that before enabling a plugin.

    2) I think this answers your question

    http://vanillaforums.org/discussion/comment/159049/#Comment_159049

    always a good idea to post questions about a plugin by going to the plugin and asking the question.

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. Peregrine

  • Mmm... I did replace the values in class.voting.plugin.php, but it doesn't work for me. After I applied the changes, Admin cannot vote, Moderator cannot vote too, and even Registered Users cannot vote.

  • peregrineperegrine MVP
    edited December 2013

    @Shinji3rd said: Mmm... I did replace the values in class.voting.plugin.php, but it doesn't work for me. After I applied the changes, Admin cannot vote, Moderator cannot vote too, and even Registered Users cannot vote.

    do they have permission?

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. Peregrine

  • @peregrine yes, they have permissions. But nevermind, I restored the original file with no modifications, and now the plugin works. Admin and moderators can vote multiple times, but regular users just one time, so that's ok with me.

Sign In or Register to comment.