• Resolved invisiblesy

    (@invisiblesy)


    Hello,

    I need to create dynamic redirect URL after the form submission. I created the hidden field with the “Submission ID” value and set up redirect as /?id={hidden-2} (where hidden-2 is the name of this field). But it redirects me to /?id=submission_id (not submission ID value, but just “submission_id” text). Am I doing something wrong?

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

    (@wpmudev-support7)

    Hello @invisiblesy

    Hope you’re doing well today!

    I was able to replicate the same behaviour with the submission ID as you’ve mentioned and I have already pinged the Forminator team to gain more insights about this.

    The redirect you’re adding seems to be correct, however, I reckon it is more related to how the submission ID is generated during the submission process.

    We will keep you posted as soon as we have further insights from the Forminator team about the expected behaviour.

    Thank you for your patience.

    Kind Regards,
    Saurabh

    Plugin Support Saurabh – WPMU DEV Support

    (@wpmudev-support7)

    Hello @invisiblesy

    An update here,

    The Forminator team was able to check this further; it appears that what you’re noticing with the Submission ID is a bug indeed. The Forminator team is already working on a fix which will be implemented in the future versions. However, we have prepared a hotfix for the issue in the meantime that can be used as a mu-plugin.

    Note: Please make a full backup of your site before uploading a fix so that there is a safety checkpoint in place.

    Below is the custom snippet hotfix which will help you fetch the submission_id

    add_filter( 'forminator_form_submit_response', 'wpmudev_fix_response_url_id', 20, 2 );
    add_filter( 'forminator_form_ajax_submit_response', 'wpmudev_fix_response_url_id', 20, 2 );
    function wpmudev_fix_response_url_id( $response, $form_id ) {
    	if ( 2960 !== intval( $form_id ) ) { // Please change 2960 to your form's ID.
    		return $response;
    	}
    
    	if ( ! empty( $response['url'] ) && false !== strpos( $response['url'], 'submission_id' ) ) {
    		$last_entry = Forminator_Form_Entry_Model::get_latest_entry_by_form_id( $form_id );
    		if ( is_object( $last_entry ) ) {
    			$response['url'] = str_replace( 'submission_id', esc_html( $last_entry->entry_id ), $response['url'] );
    		}
    	}
    
    	return $response;
    }

    In the line if ( 2960 !== intval( $form_id ) ) please make sure to change 2960 to your form ID. The form ID is the number that you see on the Forminator shortcode.

    To add the custom snippet as a mu-plugin, you will need to create a blank .PHP file for example submission_id_redirect.php and paste the snippet on the file.

    Once done, you will need to upload the file to the /wp-content/mu-plugins/ directory and then test if the redirect works fine.

    Here is how you can create a mu-plugin: https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    Please let us know how it goes.

    Kind Regards,
    Saurabh

    Thread Starter invisiblesy

    (@invisiblesy)

    @wpmudev-support7 the solution works for me, thank you!

    Plugin Support Dmytro – WPMU DEV Support

    (@wpmudevsupport16)

    Hello @invisiblesy,

    I hope you’re doing great today!

    Thank you for the confirmation. I’m marking this thread as resolved. Please feel free to reply, if you need further assistance.

    Best Regards,
    Dmytro

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

The topic ‘Variable in the redirect URL’ is closed to new replies.