• Resolved hilltoprunner

    (@hilltoprunner)


    Hello, I’d like to add multiple submission behaviors but have been unsuccessful.

    What I’d like to achieve:

    I want to hide the form and show a message and after 5 seconds, redirect the user on the same tab.

    I have been trying, but I can either do one, or the other, but not both.

    Any help would be greatly appreciated!

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @hilltoprunner,

    To start with, please do make sure you have set the “After Submission” setting to “Hide Form” with the auto close set to 5 seconds, under Behavior > Submission Behaivor > After Submission:

    View post on imgur.com

    Once done, you can try this snippet:

    <?php
    
    add_action( 'wp_footer', function(){
    	global $post;
    	?>
    	<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-233' ) {
    					setTimeout(function(){
    						window.location.replace("https://google.com");
    					}, 2000);
    				}
    			});
    		});
    	});
    	</script>
    	<?php
    }, 9999 );

    In the above code, you’ll need to update the following line with your form ID, suppose the form ID is 123, then the following code will change from:

    if ( form_id == 'forminator-module-233' ) {

    To:

    if ( form_id == 'forminator-module-123' ) {

    You’ll also have to update the following URL in the code to your redirect URL:

    						window.location.replace("https://google.com");

    The given code can be added as a mu-plugins. Please check this link on how to implement the above code as a mu-plugins:
    https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    I can confirm the code works when tested. Please do check and see whether it works fine.

    Best Regards,

    Nithin

    Thread Starter hilltoprunner

    (@hilltoprunner)

    Hi! Thank you! This works just as requested! Great work

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multiple submission behaviors’ is closed to new replies.