• Resolved khatrijay18

    (@khatrijay18)


    Hello Sir,

    Currently I am try to call short code of YOP POLL from theme’s function.php when my poll submitted successfully I want to show result only on popup with some Thank you msg.

    My Code is working fine and all other short code like Contact-form, Popup anything are working fine in pop but but when I am going to call [yop-poll id=”1″] it return same as string instead of HTML of poll.

    Will you please explain why its happen and how can I solve it?

    Please let me know if you need more detail from my side.

    Thank you.

    • This topic was modified 3 years, 10 months ago by khatrijay18.
Viewing 7 replies - 16 through 22 (of 22 total)
  • Thread Starter khatrijay18

    (@khatrijay18)

    @yourownprogrammer

    Please open link and refresh once, it will show popup after submit poll answer.

    Thanks for you time.

    Plugin Author YOP

    (@yourownprogrammer)

    @khatrijay18

    Hello

    Yes, I can see the popup showing after voting.
    But the popup only has a “Thank you for Vote” message and from what I am seeing the in the code this message is not being generated by the plugin.

    Can you send over the code you have setup for the content of the popup?

    Thread Starter khatrijay18

    (@khatrijay18)

    @yourownprogrammer

    here is code.
    custom.js

    jQuery('.basic-vote-button').on('click', function(e){
        var ele = jQuery(this); 
        setTimeout(function(){
            var getMsg = ele.parents('.basic-yop-poll-container').find('.basic-message-text')[0].innerHTML;
            var getId = ele.parents('.basic-yop-poll-container').attr('data-id');
            if(getMsg == 'Thank you for your vote'){        
                jQuery('.callPopUp .popupaoc-link').trigger('click'); // here i am triggering popup when got thank you msg
                jQuery.ajax({
                    url: ajax_script.ajax_url, //global variable provided by WP
                    type: 'GET',
                    cache: false,
                    data: {
                        'action' : 'get_contact_form',
                        'form_id' : getId
                    },
                    success: function(data){
                       jQuery('#paoc-modal-2 .paoc-popup-modal-cnt').html(data); // here i am append the code what i ajax replied.
    
                    }
                });
            }
        }, 1000);
        
    });

    function.php

    add_action('wp_ajax_get_contact_form', 'get_contact_form');
    
    function get_contact_form(){
        if(isset($_GET['form_id'])):
             $yop_poll = new YOP_Poll_Pro_Public();
             $yop_poll_params['id'] = $_GET['form_id'];
             $yop_poll_params['show_results'] = $_GET['form_id'];
             echo $yop_poll->generate_poll( $yop_poll_params );
        endif;
        exit(); 
    }

    please let me know if you need any other detail. Thank you

    • This reply was modified 3 years, 9 months ago by khatrijay18.
    Plugin Author YOP

    (@yourownprogrammer)

    @khatrijay18

    Thank you for sending over the code.
    I am seeing an error on get_contact_form() function.

    Here’s how it should be

    function get_contact_form(){
        if(isset($_GET['form_id'])):
             $yop_poll = new YOP_Poll_Pro_Public();
             $yop_poll_params['id'] = $_GET['form_id'];
             $yop_poll_params['show_results'] = '1';
             echo $yop_poll->generate_poll( $yop_poll_params );
        endif;
        exit(); 
    }

    Can you let us know when it’s updated so we can run another test?

    Plugin Author YOP

    (@yourownprogrammer)

    @khatrijay18

    Also, something else I noticed when running another test on the link you provided …

    The request to https://54.225.8.87/test_wp/wp-admin/admin-ajax.php?action=get_contact_form&form_id=1&_=xxxxxxx returns a 400 Bad Request response.

    Thread Starter khatrijay18

    (@khatrijay18)

    @yourownprogrammer ,

    i was tried with updated code but still not working ,

    and https://54.225.8.87/test_wp/wp-admin/admin-ajax.php?action=get_contact_form&form_id=1&_=xxxxxxx in this page i can see “0” only on entire page

    also i have request you to connect on skype, if its possible.

    Thread Starter khatrijay18

    (@khatrijay18)

    Thank you so much.

Viewing 7 replies - 16 through 22 (of 22 total)
  • The topic ‘How can i call do_shortcode [yop_poll id=”1″] from theme function.php’ is closed to new replies.