Support

Home Forums Event Espresso Premium Add jquery to inline php script to hide questions for certain tickets Reply To: Add jquery to inline php script to hide questions for certain tickets

Reply To: Add jquery to inline php script to hide questions for certain tickets

Author Replies
Josh # Posted on May 11, 2018 at 1:57 pm

Hi there,

The first thing that stood out that needed fixing in the code was the single quotes were not escaped. In this case it’d be simpler to replace the single quotes within double quotes within the JavaScript part of the code, like this:

function ee_custom_hide_question() {
    wp_add_inline_script( 
        'single_page_checkout',
        'jQuery( document ).ready( function( event ){
    function hideQuestion(item, index) {
        jQuery( ".spco-attendee-panel-dv.spco-attendee-ticket-" + item ).
        find( "#ee-reg-form-qstn-grp-veterans-pricing" ).hide();
    };
    ["4", "5", "6", "9"].forEach(hideQuestion);
        });'
    );
}
add_action( 'wp_enqueue_scripts', 'ee_custom_hide_question', 11 );
Do NOT follow this link or you will be banned from the site!