neuromant Posted July 8, 2010 Share Posted July 8, 2010 Hey all, I am currently using the 'I Like' plugin for wordpress.. I am trying to modify the PHP to only allow ONE vote on the whole site per user. So after one single vote, all voting should be disallowed for that IP address. I am all thumbs when it comes to syntax in PHP so any help modifying this script to do what I need it to do would be IMMENSELY appreciated! <?php require_once '../../../wp-config.php'; global $wpdb; $post_ID = $_POST['id']; $ip = $_SERVER['REMOTE_ADDR']; $like = get_post_meta($post_ID, '_liked', true); if($post_ID != '') { $voteStatusByIp = $wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."ilikethis_votes WHERE post_id = '$post_ID' AND ip = '$ip'"); if (!isset($_COOKIE['liked-'.$post_ID]) && $voteStatusByIp == 0) { $likeNew = $like + 1; update_post_meta($post_ID, '_liked', $likeNew); setcookie('liked-'.$post_ID, time(), time()+3600*24*365, '/'); $wpdb->query("INSERT INTO ".$wpdb->prefix."ilikethis_votes VALUES ('', NOW(), '$post_ID', '$ip')"); echo $likeNew; } else { echo $like; } } ?> THANK YOU!!!! Link to comment https://forums.phpfreaks.com/topic/207147-wordpress-cookies-session-id-check-anyone/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.