Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter wkrauss

    (@wkrauss)

    I figured out a solution myself. Here is the code if anyone wants to use it. I inserted it into the plugin’s file (ngg-voting.php) after the function nggv_ipHasVotedImage around line 302. Basically this will only check the database to see if a user has voted for any image based on either their user id or their ip address.

    //be sure user hasn't voted before. if they have, disable all voting
    		global $wpdb;
    		$userid = $current_user->ID;
    		if($wpdb->get_results("SELECT * FROM ".$wpdb->prefix."nggv_votes WHERE user_id = '".$wpdb->escape($userid)."'")) {
    			$GLOBALS['hasvoted'] = 'hasvoted';
    		}
    
    		$tmp = getUserIp();
    		$ip = $tmp["ip"];
    
    		if($wpdb->get_results("SELECT * FROM ".$wpdb->prefix."nggv_votes WHERE ip = '".$wpdb->escape($ip)."'")) {
    			$GLOBALS['hasvoted'] = 'hasvoted';
    		}

    If the function finds the user has voted, it will set a global variable ‘hasvoted’ to ‘hasvoted’. What I did was just then included the $GLOBALS[‘hasvoted’] to where the class is outputted for each image and if this is set it will basically append a class called “hasvoted” so you can then use CSS to hide vote links, change the color, or do whatever else you want with them. Hope this helps someone.

    The css would be something like

    .nggv_container .hasvoted {
            display: none;
    }

Viewing 1 replies (of 1 total)