YOP Poll
[resolved] Make "Other" values available for votes (4 posts)

  1. elundin
    Posted 2 years ago #

    Hi there!

    I have been looking for this kind of poll plugin for quite a while. There are a lot of bad ones out there but this one seems to have it all. Great work!

    There is only one little piece I'm looking for. I really like that ther is finally a plugin that let you use the option to add an "Other" field to the poll.

    What if you could make those entries votable aswell? That if you add a custom answer it not only show up in the result but also as a new option when you vote the next time.

    I saw that there have been som questions about this in earlier threads and I'm just interested in if you ate considering that kind of functionallity for upcoming releases and if you do - do you have a date for the next release?

    Thanks again for a great plugin! I will rate it now :)




  2. ryplittle
    Posted 2 years ago #


    I was searching for the same thing and had to change the inc/yop_poll_model.php file to get this to work the way I wanted.

    Make this edit around line 2805, and again around 2850

    /*** add the "other" entry to answers - rlittle ***/
    // $answer['other_answer_value']  = $request['yop_poll_other_answer'];
    global $wpdb;
    	INSERT INTO <code>&quot;. $wpdb->yop_poll_answers . &quot;</code> (<code>poll_id</code>, <code>answer</code>, <code>type</code>, <code>votes</code>, <code>status</code>) VALUES
    	('" . $poll_id . "', '" . $request['yop_poll_other_answer'] . "', 'default', 1, 'active')
    // if you want the "other" value to return to zero
    	UPDATE $wpdb->yop_poll_answers
    	SET votes = -1
    	WHERE poll_id = $poll_id
    		AND answer = 'Other'
    /*** end edit ***/

    Make sure you comment out $answer['other_answer_value'] = $request['yop_poll_other_answer']; like I have in the above code.

    It adds the "other" entry to the answers, which you can see in the admin for the poll settings, and if you don't want the value of "other" to return to zero, you can comment out or remove that second wpdb query.

  3. ryplittle
    Posted 2 years ago #

    I'm not sure that this is 100% correct, but I checked the database and things look good, and behave perfectly, as far as I can see. There is a lot of code in this plugin, but I found that this works for a quick fix.

  4. ryplittle
    Posted 2 years ago #

    actually, I just realized that the above code does something messed up because of the backticks in the SQL query, so do not use the above code. Instead, find it here: https://gist.github.com/ryplittle/6805319

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic