Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Nebu John – WPMU DEV Support

    (@wpmudevsupport14)

    Hi @fcis999,

    Trust you are doing good and thank you for reaching out to us.

    The following code snippet should help to display a message before redirecting to a new URL on form submission.

    <?php
    
    add_action( 'wp_footer', function(){
    	global $post;
    	if( ! $post instanceof WP_Post || ! has_shortcode( $post->post_content, 'forminator_form' ) ) {
    		return;
    	}
    	?>
    	<script type="text/javascript">
    	jQuery( document ).ready( function($) {
    		setTimeout(function() {
    			$('.forminator-custom-form').trigger('after.load.forminator');
    		},100);
    
    		$(document).on('after.load.forminator', function(event, form_id) {
    			jQuery('form.forminator-custom-form').on('forminator:form:submit:success', function (e, formData) {
    				var form_id = e.target.id;
    				if ( form_id == 'forminator-module-2910' ) {
    					setTimeout(function(){
    						window.location.replace("https://mylocal.local");
    					}, 2000);
    				}
    			});
    		});
    	});
    	</script>
    	<?php
    }, 9999 );

    Please be aware that the submission behaviour should be set to “Hide Form” under the Behaviour tab of the form. You can specify the message to display in that section. The provided code snippet will manage the redirection.

    You need to change the form ID from 2910 to your form’s ID and the redirect URL should be changed from https://mylocal.local to the desired redirect URL. The code could be added using mu-plugin, I hope the following guide helps: https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    Please feel free to get back to us if you need any clarification, we are happy to help.

    Kind Regards,
    Nebu John

    Thread Starter fcis999

    (@fcis999)

    Thanks Nebu for your kind support. I just tested it and it didn’t redirect to the other link. Not sure why? could you please advise?

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @fcis999

    I double checked the code on my lab site and it worked, could you confirm if you updated the forminator-module-2910 to your form ID replacing 2910, example forminator-module-ID_HERE

    Also added it to mu-plugins folder not inside a subfolder

    Best Regards
    Patrick Freitas

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @fcis999 ,

    We haven’t heard from you for several days now, so it looks like you don’t have more questions for us.

    Feel free to re-open this topic if needed.

    Kind regards
    Kasia

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display a message before redirecting to a new url after submission’ is closed to new replies.