WordPress.org

Forums

YOP Poll
[resolved] Can't choose only one vote per user per poll (4 posts)

  1. csburdick
    Member
    Posted 1 year ago #

    Hello, this plugin is great but I have one problem. I'm trying to create some polls and only want to user to be able to vote once per poll. I can black based on cookie or IP but only for a certain number of days, if I change the poll I want them to be able to vote on that one, but only once per user (cookie or IP is fine.) I can do this only for logged in users ("Limit Number of Votes per User: (Only for logged users)") How can I get it to only allow one vote per person per poll? Thank you!

    https://wordpress.org/plugins/yop-poll/

  2. YOP
    Member
    Plugin Author

    Posted 1 year ago #

    Hi csburdick,

    Please tell us what version of YOP Poll you use.

    Regards,

    YOP Team

  3. csburdick
    Member
    Posted 1 year ago #

    4.9.1

    Thanks

  4. YOP
    Member
    Plugin Author

    Posted 1 year ago #

    Hey csburdick,

    Edit yop_poll_model.php and in register_vote function, after

    if ( 'facebook' == $vote_type ){
              $voter['user_id']   = $facebook_user_id;
              $voter['user_type'] = $vote_type;
             }

    add

    $ip     = self::get_ip();
                                        global $wpdb;
                                        $log_id = $wpdb->get_var( $wpdb->prepare( "
         SELECT count(*)
         FROM " . $wpdb->yop_poll_logs . "
         WHERE poll_id = %d AND
         ip = %s Group by  vote_date
         ", $this->poll['id'], $ip) );
                                        if($log_id>=1) {
                                            $this->error = __( 'You have run out of votes!', 'yop_poll' );
                                            return false;
    
                                        }

    Let us know if you need more help.

    Best wishes,

    YOP Team

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic