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?
- The topic ‘Log all votes’ is closed to new replies.