• Resolved Ashutosh

    (@ashubetta)


    I am trying to setup a submission behavior when a user signs up through the Forminator form. Upon successful registration, user should see a success message for a few seconds and then the page should reload (or redirect to a different page, based on where the form is placed).

    I added two rules to the submission behavior tab, one to display a message for 10 seconds. And another to redirect to a URL (I used {embed_url} so the page would refresh). The second rule never fires. I only get the message and then nothing.

    I was able to get a redirection/reload working in a very hacky manner:

    1. Enable shortcodes in Forminator through the filter add_filter( 'forminator_replace_variables', 'do_shortcode' );.
    2. Assign a CSS class to the Submit button.
    3. Register a shortcode that listens to a click event for the Submit button class and then reloads the page after 10 seconds through JS.
    4. Place the shortcode in a hidden HTML field in the form.

    While it “works” on successful submissions, it also reloads the page when the Submit button is clicked at any point. I also tried placing the shortcode within the Submission Behavior inline message, but the script tags were stripped out.

    This is obviously way out of my capabilities. I’d really appreciate some help if this behavior is possible in Forminator. Basically, instead of the page instantly redirecting on successful submission, I’d like the user to see the message for few seconds first before the page redirects.

    The page I need help with: [log in to see the link]

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

    (@wpmudevsupport12)

    Hi @ashubetta

    I hope you are doing well.

    I am afraid it is expected:

    https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#after-submission

    When setting up multiple submission behaviors, you’ll need to configure the conditional logic for each one. If you don’t, only the first submission behavior will be processed.

    Forminator does have a native option but it will use the new tab: https://monosnap.com/file/KDeFGnYgghds2kt6WNJ2HtoNOQu3Xb

    I also found our developers created a workaround that doesn’t require an extra field:

    <?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-2636' || form_id == 'forminator-module-1632'|| form_id == 'forminator-module-1634' ) {
    					setTimeout(function(){
    						var url = "https://custom-url/";
    						window.open(url, '_blank');	
    					}, 1000);
    				}
    			});
    		});
    	});
    	</script>
    	<?php
    }, 9999 );

    Just replace the forminator-module-1634 to match your ID and remove any extra conditionals as this should work on multiple forms.

    Replace the var URL with your URL.

    Best Regards
    Patrick Freitas

    Thread Starter Ashutosh

    (@ashubetta)

    Works like magic! Thanks a ton Patrick! I really appreciate your help.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘User registration submission behaviour’ is closed to new replies.