• Resolved dagda99

    (@dagda99)


    Hi, some I didn’t know anything about php until 1 day ago. I just want to create a function that I can call through an automator, so when an user with a specific role upvotes or downvotes, the downvotes gets deleted.

    So I use wpdiscuz and I wanted to just create a function that modifies the comment metadata so that it shows the same amount of up/down votes as before. My automator and everything else works, but the number doesn’t get updated. I have tried a lot of changes and looked everywhere, but I can’t understand what’s wrong with the code.

    This is it:

    
    <?php
    
    function false_upvote($comment_id) {
      $vote = get_comment_meta( $comment_id, 'wpdiscuz_votes', true );
      return $vote - 1;
      add_comment_meta( $comment_id, 'wpdiscuz_votes', $vote ); 
    }
    
    function false_downvote($comment_id) {
      $vote = get_comment_meta( $comment_id, 'wpdiscuz_votes', true );
      return $vote + 1;
      add_comment_meta( $comment_id, 'wpdiscuz_votes', $vote );
    
    }
    ?>
    
    • This topic was modified 2 years, 9 months ago by Jan Dembowski.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter dagda99

    (@dagda99)

    Nevermind, i solved it, but I leave the code that fixed it for me in case someone in the community has a similar problem and needs the solution.

    
    <?php 
    function false_upvote($comment_id) {
    update_comment_meta( $comment_id, 'wpdiscuz_votes', $meta_value-- );
    }
    
    function false_downvote($comment_id) {
    update_comment_meta( $comment_id, 'wpdiscuz_votes', $meta_value++ );
    
    }
    ?>
    
Viewing 1 replies (of 1 total)
  • The topic ‘Limiting comment voters per post failing’ is closed to new replies.