I am using Gravity forms with Wordpress. For project I want to add function that allow to redirect to different pages based on condition: loginin person didnt submit specific form. For example after registration user forearded to second form. In first login he didnt submit this second form, so every time person login in code need to check wheather he have entry of specific for or not: if not redirext to this form: if he have entry- redirect to other form.

  • Have you inquired with Gravity Forms? This sounds like you need to record which forms they have already filled out to each users user_meta every time a form is completed. You'll need gravity forms help for this as you'll need to hook into their submission process. Failing that, you can probably write an AJAX method to also write to the user_meta DB but you'd have to be sure that the form was successfully submitted. (Not sure why you're using Gravity Forms for this - seems like this would have been a lot simpler to just build the forms yourself.) Oct 26, 2023 at 13:40
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
    – Community Bot
    Oct 26, 2023 at 13:40

1 Answer 1


Once a user logs in, you'd want to check whether they've made a submission to your particular form. Gravity Forms keeps all of its entries (which is what it calls form submissions) stored away neatly, so we can simply check in there. If the user has no entries for your form, we'll send them one way, and if they do, we'll send them another.

For a bit of a nudge in the right coding direction: You might use the gform_user_registration_login_args filter to adjust the login redirect. Within that, you can use the GFAPI::get_entries function to check if the user has submitted a form. Here’s a super basic idea of what your function might look like in PHP code:

function custom_login_redirect( $login_args ) {
    // Get the current user info
    $current_user = wp_get_current_user();
    // Check for entries of form ID 2 (or whatever your form ID is) by the current user
    $search_criteria['field_filters'][] = array( 'key' => 'created_by', 'value' => $current_user->ID );
    $entries = GFAPI::get_entries( 2, $search_criteria );

    // If there are no entries...
    if( empty( $entries ) ) {
        // Redirect to Form 2
        $login_args['redirect'] = get_permalink( 123 ); // Your Form 2 page ID
    } else {
        // Redirect somewhere else
        $login_args['redirect'] = get_permalink( 456 ); // Another page ID
    return $login_args;
add_filter( 'gform_user_registration_login_args', 'custom_login_redirect' );

A quick breakdown: we’re looking into the entries of Form 2 (or whatever your second form is) for submissions by the currently logging-in user. If we don’t find any, we send them to Form 2, and if we do find some, we send them elsewhere. Note that you’ll want to replace 123 and 456 with your actual Page IDs where your forms live.

Remember to have a thorough test to make sure it all works as you expect it to. Coding can be a bit of an adventure, sometimes! Also, crafting such a redirect might have some implications on the user experience, so perhaps a little notification to the user about why they are being redirected might be a warm little addition to smoothen their journey on your site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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