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.