WordPress.org

Ready to get started?Download WordPress

Forums

YOP Poll
[resolved] form submission without clicking "Vote" [feature request] (10 posts)

  1. john.horning
    Member
    Posted 7 months ago #

    I have a long poll and the Vote button is hidden until you scroll down. Some users make a selection and don't realize they need to scroll down and click Vote. It would be very useful if users could vote without having to click Vote". I don't know much about javascript, but perhaps it could be used for that purpose.
    John

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

  2. YOP
    Member
    Plugin Author

    Posted 7 months ago #

    Hi John,

    Please edit inc/yop_poll_model.php and on line 3699 replace these 2 blocks

    if( $multiple_answers ) {}
    else {}

    with

    if ( $multiple_answers ) {
    							if ( isset( $answer_options['is_default_answer'] ) && 'yes' == $answer_options['is_default_answer'] )
    								$temp_string	= str_ireplace( '%POLL-ANSWER-CHECK-INPUT%', '<input type="checkbox" checked="checked" value="'.$answer['id'].'" name="yop_poll_answer['.$answer['id'].']" id="yop-poll-answer-'.$answer['id'].'" />', $m[5] );
    							else
    								$temp_string	= str_ireplace( '%POLL-ANSWER-CHECK-INPUT%', '<input type="checkbox" value="'.$answer['id'].'" name="yop_poll_answer['.$answer['id'].']" id="yop-poll-answer-'.$answer['id'].'" />', $m[5] );
    						}
    						else {
    							if ( isset( $answer_options['is_default_answer'] ) && 'yes' == $answer_options['is_default_answer'] )
    								$temp_string	= str_ireplace( '%POLL-ANSWER-CHECK-INPUT%', '<input type="radio" onclick="if( jQuery(this).is(\':checked\') ) jQuery(this).closest(\'form\').find(\'button[class=yop_poll_vote_button]\').click()" checked="checked" value="'.$answer['id'].'" name="yop_poll_answer" id="yop-poll-answer-'.$answer['id'].'" />', $m[5] );
    							else
    								$temp_string	= str_ireplace( '%POLL-ANSWER-CHECK-INPUT%', '<input type="radio" onclick="if( jQuery(this).is(\':checked\') ) jQuery(this).closest(\'form\').find(\'button[class=yop_poll_vote_button]\').click()" value="'.$answer['id'].'" name="yop_poll_answer" id="yop-poll-answer-'.$answer['id'].'" />', $m[5] );
    						}

    Please note that once you save the changes they will apply on all your polls.

    Also, if in "Options" you set "Vote as WordPress User" and "Vote as Anonymous User" to "Yes", then the vote will not be registered unless
    the users click on the corresponding buttons.

    Best wishes,

    YOP Team

  3. john.horning
    Member
    Posted 7 months ago #

    Thanks! Works like a charm! You guys are the best!

  4. john.horning
    Member
    Posted 7 months ago #

    An additional note - I tried deleting the "vote" button from the template, but nothing happens when you select an answer in the poll. So I put it back in, but used CSS to hide it (display:none).

  5. john.horning
    Member
    Posted 7 months ago #

    Okay- I may need to hire you on this one. Your javascript code above works fine when using the shortcode in a regular post, but now I'm trying to put it on a page where shortcodes don't normally work. I inserted this into the template file:

    <?php echo do_shortcode('[yop_poll id="1"]'); ?>

    Now the poll shows up, but nothing happens when I select an answer. I then made sure the javascript was called in the head by copying and pasting it from a page where it was working, but still no luck.

    Any suggestions?

  6. YOP
    Member
    Plugin Author

    Posted 7 months ago #

    Hey John,

    Please add the JavaScript code in the footer and try again.

    Regards,

    YOP Team

  7. john.horning
    Member
    Posted 7 months ago #

    Thanks, but still no luck. Can you tell me what the javascript code should be or at least the names of the files?

  8. YOP
    Member
    Plugin Author

    Posted 7 months ago #

    Hi John,

    Please send us a link to the page where you have the poll.

    Best wishes,

    YOP Team

  9. YOP
    Member
    Plugin Author

    Posted 7 months ago #

    Hey John,

    In the file you inserted <?php echo do_shortcode('[yop_poll id="1"]'); ?>
    try to replace this line with <?php return_yop_poll(1); ?>

    Regards,

    YOP Team

  10. john.horning
    Member
    Posted 7 months ago #

    I tried your php code above - no luck, although it may work if I played around more with the javascript.

    I did, however, find a solution - iframe! Check it out here:
    http://bullbord.com/apps/contest/best-kent-restaurant/

    still a work in progress...

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.