Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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

    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.

    Hey,

    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;
    
    $wpdb->query(
    	"
    	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
    $wpdb->query(
    	"
    	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.

    Now, it seems that this is the default behavior… Can it be un-checked by default?

Viewing 4 replies - 1 through 4 (of 4 total)