Close pop-up when clicked on the call to action button

I have a popup with a call to action button on my site. I need the pop-up closed when clicked on the call to action button is clicked. Please suggest a workaround for this.

  • Pawel Pela
    • Ex Staff

    Hello again Erin !

    My apologies! The developer shared a screenshot of a section that is going to be added in an upcoming version of the plugin. Until this is publicly available, we’ve created a task for our Second Line Support team to create a workaround for you. They will reply in this ticket.

    Kind regards,
    Pawel

  • Alessandro
    • Nightcrawler & Daydreamer

    Hello Erin.

    On SLS team, we developed a co snippet to close the pop-up when user click on the CTA button.

    function wpmudev_hustle_close_on_cta_click(){
    
        if ( ! wp_script_is( 'jquery', 'done' ) ) {
            wp_enqueue_script( 'jquery' );
        }
    
        wp_add_inline_script( 'jquery', 
            "jQuery(document).ready(function($){
                $(document).on('click', '.hustle-button-cta', function(){
                    $('.hustle-popup').find('.hustle-button-close').trigger('click');
                });
            });"
        );
    
    }
    
    add_action( 'wp_enqueue_scripts', 'wpmudev_hustle_close_on_cta_click' );

    Append this code to your theme’s functions.php and it will work.

    Note: We always recommend to append any snippets in your child’s theme functions.php to allow parent themes to be updated without losing your modifications.

    Let us know if this worked for you.

    Kind regards,
    
Alex.