I've been researching this for a few days now and found many voting plugins - unfortunately none of them does exactly what I need, so I am trying to hack some functions/scripts that I've found by searching online.
I'm working with this script, now: http://bavotasan.com/2011/a-better-voting-system-for-wordpress/
I'm trying to figure out a way to only allow the IP to vote once on the website. Essentially, if they vote on one post - they cannot vote on another.
This post is similar to this thread, Wordpress Vote Plugin - Vote Once and Track User
add_action("wp_ajax_add_votes_options", "add_votes_options");
add_action("wp_ajax_nopriv_add_votes_options", "add_votes_options");
function add_votes_options() {
if (!wp_verify_nonce($_POST['nonce'], 'voting_nonce'))
return;
$postid = $_POST['postid'];
$ip = $_POST['ip'];
//$voter_ips = get_post_meta($postid, "voter_ips", true);
// use an option instead
$voter_ips = get_option( "wpse_59080_voter_ips", true );
if(!empty($voter_ips) && in_array($ip, $voter_ips)) {
echo "null";
die(0);
} else {
$voter_ips[] = $ip;
// update_post_meta($postid, "voter_ips", $voter_ips);
update_option( "wpse_59080_voter_ips", $voter_ips );
}
//$current_votes = get_post_meta($postid, "votes", true);
$current_votes = get_option( "wpse_59080_voter_ips", true );
$new_votes = intval($current_votes) + 1;
// update_post_meta($postid, "votes", $new_votes);
// use an option instead
update_option( "wpse_59080_voter_ips", $voter_ips );
$return = $new_votes>1 ? $new_votes." votes" : $new_votes." vote";
echo $return;
die(0);
}