Pass value between hustle pop-ups

We have multiple downloadable items on the same page, all triggering a popup with a different ID.

I don’t want the user to fill out their email every time, is there a way the user only fills out its email once?

  • Alessandro
    • Nightcrawler & Daydreamer

    Hello Bart!

    We developed a small snippet to auto-fill all email fields of all popups existing on a page.

    Use the following in your theme’s functions.php:

    function wpmudev_hustle_popup_autofill_email() {
      if ( ! wp_script_is( 'jquery', 'done' ) ) {
            wp_enqueue_script( 'jquery' );
      }
      wp_add_inline_script( 'jquery', "
        jQuery(document).ready(function($){
            var selector = '.hustle-popup .hustle-input[type=\"email\"]';
            $(document).on('focusout', selector, function(){
                var email = $(this).val();
                $(selector).each(function(){
                    $(this).val(email);
                });
            });
        });"
      );
    }
    
    add_action( 'wp_enqueue_scripts', 'wpmudev_hustle_popup_autofill_email' );

    Feel free to alter the code and add support for First name and Last name as well.

    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.

  • Bart
    • New Recruit

    Hi Alex,

    Thanks a lot for the custom script – really cool you guys are going above and beyond to help search for a solution.

    For a feature request it would be cool if Hustle could detect this automatically, so so this option can be triggered from the backend easily.

    Thanks again for the workaround!