1

I have a Gravity Forms page set up where, after you fill out the form, you are taken to a confirmation page where you can download some resources.

The problem with this setup is: Let's say someone fills out the form and then gets to the confirmation page, and then leaves the site. Later they remember they need to download a different file from the confirmation page. They come back to the site and have to fill out the form again.

Is there some option in Gravity Forms to specify a cookie or something that indicates that the user already filled out the form and to take them directly to the confirmation page again?

  • 1
    To answer your question: No, there isn't. You have to make it posssible using GF hooks. – Nabil Kadimi Oct 31 '16 at 20:48
3

Here's some code on how you could simply leverage the gform_after_submission hook of Gravity Forms to set a cookie based on your form ID once submitted, then check for that on the confirmation page by hooking into template_redirect.

In order to customize the functionality, you'll want to look at the docs for setcookie, gform_after_submission and template_redirect.

For the form

// Make sure to swap out {your_form_id} with the ID of the form.

add_action( 'gform_after_submission_{your_form_id}', 'wpse_set_submitted_cookie', 10, 2 );

function wpse_set_submitted_cookie( $entry, $form ) {

    // Set a third parameter to specify a cookie expiration time, 
    // otherwise it will last until the end of the current session.

    setcookie( 'wpse_form_submitted', 'true' );
}

For the page

add_action( 'template_redirect', 'wpse_protect_confirmation_page' );

function wpse_protect_confirmation_page() {
    if( is_page( 'my-confirmation-page' ) && ! isset( $_COOKIE['wpse_form_submitted'] ) ) {
        wp_redirect( home_url( '/my-form/' ) );
        exit();
    }
}
1

This is pretty close to that:

http://gravitywiz.com/submit-gravity-form-access-content/

Based on your scenario and assuming your confirmation content is static, you would setup a WordPress page with your desired content. You would then configure the snippet so the user must submit the form to access that content. On subsequent visits, it would just show the content (without the form) if the user already submitted it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.