Re-Open a Popup On Form Submission

When a form doesn't support AJAX Submission, this code is needed to re-open the form. You'll most likely want this so users can see form submit "success" messages. Otherwise, the user might not know if their submission got processed correctly, or if there was an error with their submission.

The $_POST key and value in the code below will vary based on your form and will need to be replaced.

Also, make sure you replace the "123" with your proper popup ID # found on the All Popup Screen.

You can add the PHP code snippet to your child theme's functions.php file or with a third-party plugin such as My Custom Functions.

    <?php
    /*
    /* Add the following code to your theme (or child-theme)
    /*   'functions.php' file starting at 'add_action()'.
    */
    add_action( 'wp_footer', 'pum14_popup_reg_form_check', 1000 );
    /*
     * Reopen a non-AJAX submitted form after form submit.
     *
     * @since 1.0.0.
     *
     * @return void
     */
    function pum14_popup_reg_form_check() {
        if ( isset( $_POST['form_id'] ) && $_POST['form_id'] == 'my_form' ) {
            ?>
            <script type="text/javascript">
                PUM.open(123);
            </script>
            <?php
        }
    }

View the source on GitHub.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.