Title: Bugfix for wp_gdsr_rating_comment function
Last modified: August 20, 2016

---

# Bugfix for wp_gdsr_rating_comment function

 *  Resolved [renet](https://wordpress.org/support/users/renet/)
 * (@renet)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/bugfix-for-wp_gdsr_rating_comment-function/)
 * Hi everyone,
 * as some may have encountered already (and as some have already posted here: [http://wordpress.org/support/topic/plugin-gd-star-rating-how-to-get-comment-thumbs-count](http://wordpress.org/support/topic/plugin-gd-star-rating-how-to-get-comment-thumbs-count))
   there is a problem with the wp_gdsr_rating_comment function for getting the comments
   rating information. The thumbs votes always count 0, even though some thumbs 
   votes have already been made. As I needed this to work, I did a little research
   and this is what I found out:
 * The problem exists due to an error in the GDSRCommentRating class, which can 
   be found in _[plugin’s-folder]/code/cls/results.php_ (lines 115 to 166).
 * To fix this, simply replace all occurrences of **$post_data** in the GDSRCommentRating
   function of this class with **$comment_data**. This should do the job.
 * The fixed class should look like this:
 *     ```
       class GDSRCommentRating {
           var $comment_id;
           var $post_id;
           var $review;
           var $user_votes;
           var $visitor_votes;
           var $votes;
           var $user_rating;
           var $visitor_rating;
           var $rating;
           var $thumbs_user_rating = 0;
           var $thumbs_visitor_rating = 0;
           var $thumbs_rating = 0;
           var $thumbs_user_votes;
           var $thumbs_user_votes_plus;
           var $thumbs_user_votes_minus;
           var $thumbs_visitor_votes;
           var $thumbs_visitor_votes_plus;
           var $thumbs_visitor_votes_minus;
           var $thumbs_votes;
           var $thumbs_votes_plus;
           var $thumbs_votes_minus;
   
           /**
            * Class constructor.
            *
            * @param object $comment_data input data
            */
           function GDSRCommentRating($comment_data) {
               $this->comment_id = $comment_data->comment_id;
               $this->post_id = $comment_data->post_id;
               $this->review = $comment_data->review;
               $this->user_votes = $comment_data->user_voters;
               $this->visitor_votes = $comment_data->visitor_voters;
               $this->votes = $this->user_votes + $this->visitor_votes;
               if ($comment_data->user_voters > 0) $this->user_rating = number_format($comment_data->user_votes / $comment_data->user_voters, 1);
               if ($comment_data->visitor_voters > 0) $this->visitor_rating = number_format($comment_data->visitor_votes / $comment_data->visitor_voters, 1);
               if ($this->votes > 0) $this->rating = number_format(($comment_data->visitor_votes + $comment_data->user_votes) / ($comment_data->visitor_voters + $comment_data->user_voters), 1);
               $this->thumbs_votes = $comment_data->user_recc_plus + $comment_data->user_recc_minus + $comment_data->visitor_recc_plus + $comment_data->visitor_recc_minus;
               $this->thumbs_rating = $comment_data->user_recc_plus - $comment_data->user_recc_minus + $comment_data->visitor_recc_plus - $comment_data->visitor_recc_minus;
               $this->thumbs_votes_plus = $comment_data->user_recc_plus + $comment_data->visitor_recc_plus;
               $this->thumbs_votes_minus = $comment_data->user_recc_minus + $comment_data->visitor_recc_minus;
               $this->thumbs_visitor_votes = $comment_data->visitor_recc_plus + $comment_data->visitor_recc_minus;
               $this->thumbs_visitor_rating = $comment_data->visitor_recc_plus - $comment_data->visitor_recc_minus;
               $this->thumbs_visitor_votes_plus = $comment_data->visitor_recc_plus;
               $this->thumbs_visitor_votes_minus = $comment_data->visitor_recc_minus;
               $this->thumbs_user_votes = $comment_data->user_recc_plus + $comment_data->user_recc_minus;
               $this->thumbs_user_rating = $comment_data->user_recc_plus - $comment_data->user_recc_minus;
               $this->thumbs_user_votes_plus = $comment_data->user_recc_plus;
               $this->thumbs_user_votes_minus = $comment_data->user_recc_minus;
           }
       }
       ```
   
 * I’m working with the version 1.9.21 of the plugin. I hope this helps some people.
 * Regards,
    René
 * [http://wordpress.org/extend/plugins/gd-star-rating/](http://wordpress.org/extend/plugins/gd-star-rating/)

The topic ‘Bugfix for wp_gdsr_rating_comment function’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/gd-star-rating_333071.svg)
 * [GD Star Rating](https://wordpress.org/plugins/gd-star-rating/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gd-star-rating/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gd-star-rating/)
 * [Active Topics](https://wordpress.org/support/plugin/gd-star-rating/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gd-star-rating/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gd-star-rating/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [renet](https://wordpress.org/support/users/renet/)
 * Last activity: [13 years, 5 months ago](https://wordpress.org/support/topic/bugfix-for-wp_gdsr_rating_comment-function/)
 * Status: resolved