• I only realised upon launching a simple microsite how the voting worked. Logged in, get_current_user_id(). Logged out, $_SERVER[‘REMOTE_ADDR’] (IP address). This made logged out votes on the same network cancelled each other out. Which wasn’t the desired result.

    I read the response to a couple of posts on here and understand the principle of simplicity. I ask you make very clear in the information notes of the plugin how this works. What threw me was the logged in versus logged out. All my visitors are logged out.

    Anyway, in the spirit of open source I thought I would share my work around, so it might help someone else. NB: This is a last minute fix and there is no doubt a better method.

    In plugins/kodex-posts-likes/public/class-kodex-posts-likes-public.php I changed the get_user_identifier() function line from:

    $code = $_SERVER['REMOTE_ADDR']
    to
    $code = $_SERVER['REMOTE_ADDR'] . $_COOKIE['my_cookie_name'];

    I pasted the random string generator code give here https://kodex.pierros.fr/php/generer-chaine-aleatoire-php/ in functions.php of my theme.

    In header.php of my theme I added at the top of the page:

    
    if(!isset($_COOKIE['my_cookie_name'])) {
    	$cookie_name = 'my_cookie_name';
    	$cookie_value = kodex_random_string(); // use random string
    	setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day
    	$_COOKIE['my_cookie_name'] = $cookie_value;
    }

    Which seemed to be the quickest fix for me. Sure you can vote multiple times on different browsers, clear cookies and vote again. This didn’t matter as there was nothing significant other than a like needed.

    Great plugin btw, thanks!

    • This topic was modified 7 years, 6 months ago by whoo.
  • The topic ‘More info needed about voting on LAN’ is closed to new replies.