• 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, 6 months ago by khatrijay18.
Viewing 15 replies - 1 through 15 (of 22 total)
  • Thread Starter khatrijay18

    (@khatrijay18)

    `add_action(‘wp_ajax_get_contact_form’, ‘get_contact_form’);

    function get_contact_form(){

    if(isset($_GET[‘form_id’])):
    echo do_shortcode(‘[contact-form-7 id=”152″ title=”Contact page”]’);
    echo do_shortcode(‘[popup_anything id=”461″]’);
    echo do_shortcode(‘[yop_poll id=”1″]’);
    //echo do_shortcode(‘[yop_poll id=”‘.$_GET[‘form_id’].'”]’);
    endif;
    exit();
    }

    Here is my code in this contact-form-7 and popup_anything work as expected but yop_poll not working its return ‘[yop_poll id=”1″]’

    Plugin Author YOP

    (@yourownprogrammer)

    Hello

    This seems to be caused by the way we define the shortcodes within the plugin.
    An workaround would be the code below

    $yop_poll = new YOP_Poll_Public();
    $yop_poll_params['id'] = $_GET['form_id'];
    $yop_poll_params['tracking_id'] = '';
    echo $yop_poll->generate_poll( $yop_poll_params );
    

    This code should replace

    echo do_shortcode(‘[yop_poll id=”‘.$_GET[‘form_id’].'”]’);

    I hope this helps.

    • This reply was modified 3 years, 6 months ago by YOP.
    Thread Starter khatrijay18

    (@khatrijay18)

    Thank you so much @yourownprogrammer,

    Here I want to add one more point, $yop_poll = new YOP_Poll_Public(); or $yop_poll = new YOP_Poll_Pro_Public(); whatever function in you public.php.

    Thread Starter khatrijay18

    (@khatrijay18)

    @yourownprogrammer Need one more minor help

    Your code id working fine now but when i am trying to call with show_results its not working as expected.

    Like when we passing show_results parameter at that time the poll should be return result only

    Here is my code.

    $yop_poll = new YOP_Poll_Pro_Public();
             $yop_poll_params['id'] = $_GET['form_id'];
             $yop_poll_params['tracking_id'] = '';
             $yop_poll_params['show_results'] = $_GET['form_id'];
             echo $yop_poll->generate_poll( $yop_poll_params );

    I was tried to find out some way but not able to get success. Please Help!

    Thank you.

    Thread Starter khatrijay18

    (@khatrijay18)

    For more Clearance (i am not able to upload screenshot so i am trying my best as words)

    I have load total 3 Polls which 2 polls are as questions and 1 poll is show only results (this things are working fine with mention below array)

    Array ( [id] => 1 [results] => 0 [tracking_id] => [show_results] => )
    Array ( [id] => 2 [results] => 0 [tracking_id] => [show_results] => )
    Array ( [id] => 1 [results] => 0 [tracking_id] => [show_results] => 1)

    Whenever i am going to open poll on new popup in popup i am getting this array
    Array ( [id] => 1 [show_results] => 1)
    but Poll loaded with question not result only.

    I hope you got me what i want to explain.

    Thanks

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

    (@yourownprogrammer)

    Hello

    You should be able to display results with this extra line

    $yop_poll_params['show_results'] = '1';

    I hope this helps.

    Thread Starter khatrijay18

    (@khatrijay18)

    @yourownprogrammer Yes of course i should, but the thing is i am loading it on popup when poll submitted. i can see the poll in popup but its asking question instead of result.

    I have already added your code as mention above one of my example.

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

    (@yourownprogrammer)

    @khatrijay18

    Can you paste here the exact code you are currently using to display the results in the popup?

    Thread Starter khatrijay18

    (@khatrijay18)

    This is my script which trigger popup first and then call YOP_POLL and whatever it return it will replace in popup HTML.

    jQuery('.callPopUp .popupaoc-link').trigger('click');
                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){
                        console.log(data);
                        //jQuery('#content').append('hello Here : ', data);
                        jQuery('#paoc-modal-2 .paoc-popup-modal-cnt').html(data);
                    }
                });

    And Here is my AJAX call.
    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();
    }

    Thank you

    Plugin Author YOP

    (@yourownprogrammer)

    Here is the updated code to use on the AJAX call

    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();
    }

    Let us know how it goes.

    Thread Starter khatrijay18

    (@khatrijay18)

    Hi @yourownprogrammer ,

    I tried to pass static value on show_results but its doing same it return poll as question format instead of result format.

    Plugin Author YOP

    (@yourownprogrammer)

    @khatrijay18

    Yes, it does return the poll as question format.
    Once done, a js should kick in to display the results.

    Can you share a link so we can run a test?

    Thread Starter khatrijay18

    (@khatrijay18)

    Hello @yourownprogrammer ,

    Sorry for delay, I was create demo link for you reference.

    Here it is: https://54.225.8.87/test_wp/index.php/recourse/

    Please check and let me know if you required anything else.

    Thread Starter khatrijay18

    (@khatrijay18)

    Hello @yourownprogrammer ,

    Did you check the link? do you need anything else from my side? Please let me know.

    Thank you.

    Plugin Author YOP

    (@yourownprogrammer)

    @khatrijay18 apologies for the delay in getting back to you.

    I looked at the link you sent over, run a test on both polls you have setup and in both cases I am seeing only a thank you message in the popup.

    I thought it was displaying the poll?

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