User Registration is one of the most powerful capabilities Gravity Forms offers, giving you total control over the user registration process. Paired with Auto Login and Better User Activation, new user on-boarding in WordPress is seamlessly elevated from a process to an experience.
Keeping that process free of obstacles is important. A common obstacle happens when a user forgets that you have an account on your site. They navigate to the user registration page, fill out all the required fields, and are shown an error message after submitting. It’s a frustrating process that has wasted their time.
Using Populate Anything, you can remove this obstacle by checking to see if they have already registered and displaying a login link when appropriate.
In this tutorial, we’re going to add a login link that appears if a user attempts to register on your site with an email that already exists. This article assumes you’ve already setup your User Registration feed.
Once you have GF Populate Anything installed, follow the steps below to build the form.
Step 1 – Add an Email Field
All user registrations in Gravity Forms require a valid email address. If your form doesn’t already contain an Email field, add one now.
Step 2 – Check If the User Has Already Registered
Next, add a Single Line Text field to the form and name it “Email Check”. In this field, we’ll use Populate Anything to check to see if the entered email has already been registered. To do this, set Populate Anything to register from User meta and filter the User Email to the name of the Email field you created in Step 1.
Set the Value Template for this field to Email. What this will do is if the user’s email is connected to an account, the field value will be set to the found email. If the email hasn’t been used, the value will be blank.
Since this field is solely going to be used to determine if the entered email already exists, I suggest marking its Visibility to Hidden. Your users don’t need to see it on the form.
Step 3 – Show a Login Link
With our email check in place, the next step is to add a login link when the email already exists. To do this, add an HTML field to the form. Insert your login link and accompanying text into the Content of that field.
Enable Conditional Logic on the field and set it to show the field if the value of the “Email Check” field is not blank. Remember, if the email doesn’t exist, the value is blank; if the email does exist, the value is the user’s email.
With the Conditional Logic in place on the HTML field, your user registration form is ready to go. When a user enters their email, Populate Anything checks to see if it already exists. If it does, the login link displays.
Taking It Further
Hide Submit Button
Adding the login link doesn’t prevent the user from submitting the form. Gravity Forms User Registration will prevent the registration from happening by displaying a validation message that an account with that email already exists, but you can take it one step further by hiding the Submit button.
To do this, navigate to the form’s settings page, scroll down to Form Button, and enable Conditional Logic. Use the same logic from the HTML field, but set it to Hide the field if “Email Check” is not blank.
When a user enters an existing email, the Submit button is replaced with your login link.