WordPress.org

Forums

YOP Poll
Displaying nicknames of voters in results (2 posts)

  1. merkaba5
    Member
    Posted 1 year ago #

    Hi! Thanks for a great plugin!

    Prompt, how to make the list of nicknames of registered users answered each question displaying in the poll results?

    Something like this:

    Answer 1 - 60% ( 6 votes )
    User1, User2, User3, User4, User5, User6
    result bar

    Answer 2 - 40% ( 4 votes )
    User7, User8, User9, User10
    result bar

    Poll open only for registered users.

    Sorry for my bad english & thanks!

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

  2. YOP
    Member
    Plugin Author

    Posted 1 year ago #

    Hi merkaba5,

    Edit inc/yop_poll_model.php and in answer_result_replace_callback function, approximately on line 3268 you will see

    if ( 'yes' == $poll_options['poll_answer_html_tags'] ){
                                $temp_string = str_ireplace( '%POLL-ANSWER-LABEL%', yop_poll_kses( stripslashes( $answer['answer'] ) ), $temp_string );
                            }
                            else {
                                $temp_string = str_ireplace( '%POLL-ANSWER-LABEL%', yop_poll_kses( esc_html( stripslashes( $answer['answer'] ) ) ), $temp_string );
                            }

    Before if ( 'yes' == $poll_options... , from logs table ( $wpdb->yop_poll_logs ) you can select the user_ids of those who voted based on the poll_id and $answer['id'] that you'll find in the logs table

    Also, using those user_ids you can extract the usernames from
    $wpdb->users

    Regards,

    YOP Team

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.