Title: Log all votes
Last modified: August 21, 2016

---

# Log all votes

 *  [Will24_](https://wordpress.org/support/users/will24_/)
 * (@will24_)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/log-all-votes/)
 * How can I log the IPs of all voters?
 * The plugin’s “help” section is confusing – it gives me code but doesn’t tell 
   me which file to put the code in. I put it in the plugin’s index.php.
 * I added this function in the class:
 *     ```
       public function log_star_rating($post_id, $stars, $ip) {
                           $file = 'logs.txt';
                           $fh   = fopen($file, 'a');
                           fwrite($fh, 'PID: ' . $post_id . ' Stars: ' . $stars . ' IP: ' . $ip . '\n');
                           fclose($fh);
       }
       ```
   
 * And amongst the other add_action()s, I added this:
 *     ```
       add_action('kksr_rate', array($kkStarRatings_obj, 'log_star_rating'));
       ```
   
 * Now it just says “An error occurred” when I try to rate a post.
 * I also tried adding the code in my theme’s functions.php file but it never created
   the logs.txt file.
 * Any ideas?
 * [https://wordpress.org/plugins/kk-star-ratings/](https://wordpress.org/plugins/kk-star-ratings/)

The topic ‘Log all votes’ is closed to new replies.

 * ![](https://ps.w.org/kk-star-ratings/assets/icon-256x256.jpg?rev=2140680)
 * [kk Star Ratings - Rate Post & Collect User Feedbacks](https://wordpress.org/plugins/kk-star-ratings/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/kk-star-ratings/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/kk-star-ratings/)
 * [Active Topics](https://wordpress.org/support/plugin/kk-star-ratings/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/kk-star-ratings/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/kk-star-ratings/reviews/)

## Tags

 * [add_action](https://wordpress.org/support/topic-tag/add_action/)
 * [custom function](https://wordpress.org/support/topic-tag/custom-function/)
 * [log](https://wordpress.org/support/topic-tag/log/)

 * 0 replies
 * 1 participant
 * Last reply from: [Will24_](https://wordpress.org/support/users/will24_/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/log-all-votes/)
 * Status: not resolved