public function set_user_vote( $post_id, $votes, $vote, $ip ) {

		global $wpdb;

		$table_name = $wpdb->prefix . 'efg_custom_rating';

		$result = $wpdb->get_row(
			"
            SELECT id, vote 
            FROM   $table_name 
            WHERE  ip      = '$ip'
            AND    post_id = $post_id
        "
		);

		if ( ! isset( $result->id ) && ! isset( $result->vote ) ) {

			$wpdb->insert(
				$table_name,
				[
					'post_id' => $post_id,
					'ip' => $ip,
					'vote' => $vote,
				],
				[ '%d', '%s', '%d' ]
			);

			$votes[ $vote ]++;

		} else {

			if ( $result->vote != $vote ) {

				$wpdb->update(
					$table_name,
					[
						'post_id' => $post_id,
						'ip' => $ip,
						'vote' => $vote,
					],
					[ 'id' => $result->id ],
					[ '%d', '%s', '%d' ],
					[ '%d' ]
				);

				$votes[ $result->vote ]--;
				$votes[ $vote ]++;
			}
		}

		return $votes;
	}