Gravity Forms conditional logic: the ultimate guide

Gravity Forms conditional logic: the ultimate guide

Gravity Forms conditional logic: the ultimate guide


All the different ways to use conditional logic inside Gravity Forms. Hiding form fields, displaying content based on user inputs, using the powerful conditional shortcode, and more.

Estimated reading time: 13 minutes

Conditional logic is a powerful way to optimize your Gravity Forms and create a more personalized user experience on your WordPress website.

Research shows that it only takes users 50 milliseconds to form an opinion about your site!

Yes, that’s right – Internet users have very short attention spans. If your content isn’t relevant and easy to navigate, visitors will exit the page.

The same thing goes for forms: you need to simplify your forms to keep users’ attention!

Forms are a powerful marketing tool. You can use them to collect leads, survey your customers, sell products, and much more. But if your forms are long and complicated, users are going to lose interest long before they click “submit”.

If you’re not using conditional logic on your forms, you should be! In this guide, we will look at all the ways you can use conditional logic inside Gravity Forms to improve the functionality of your website.

Keep reading to find out everything you need to know about Gravity Forms conditional logic.

What is conditional logic?

Conditional logic is a way of making decisions based on certain parameters. It’s a process that says “If X, then do Y, but if Z then do W”.

Conditional logic gives you the ability to create powerful forms that hide or display fields based on certain rules being met.

But conditional logic doesn’t end there.

You can use conditional logic to send notifications to users based on certain information or display different confirmation messages depending on what the user entered in their submission.

💡 Pro tip: Using GravityView’s powerful [gvlogic] shortcode, you can use conditional logic on posts, pages, or anywhere on your WordPress website. We cover this in-depth below.

Why is conditional logic important?

Conditional logic allows you to build interactive forms that display relevant fields and improve the overall user experience.

Think about it. If your forms contain fields that users find irrelevant, they are less likely to complete the submission process. Users are more willing to invest time into businesses that connect with them on a personal level.

But conditional logic in Gravity Forms isn’t limited to form fields. You can use conditional logic to deliver relevant, personalized messages to users in a variety of ways:

  • Display different information to a user depending on their role  
  • Personalize email notifications 
  • Send relevant confirmation messages
  • Create powerful, complex workflows

Here are some examples of how this works.

Gravity Forms conditional logic examples

So you can see the importance of conditional logic but you’re still confused about how it works? Here are some examples of conditional logic in action.

Display or hide form fields

Okay, so let’s say you want to survey your readers to find out how many of them enjoy drinking coffee and what their favorite type of coffee is.

Here, we have a simple form that asks for the reader’s name and then asks them whether they drink coffee. If they select “No”, that’s the end of the form. They can click “Submit” and everything is done.

A Gravity Forms with two fields—Name and 'Do you drink coffee?'. The second field is set to 'No'.

But if they select “Yes”, a new field appears asking them whether they prefer Lattes, Cappuccinos, or Americans.

The same for with a 'Do you drink coffee?' field set to 'yes'. There is now a new checkbox field labeled 'What's your favorite kind?'

Do you see how we’ve simplified the user experience? It doesn’t make much sense to ask the user what their favorite kind of coffee is if they already told us they don’t drink coffee!

Here we’re using conditional logic to display the last field when the user selects “Yes” and keep it hidden when the user selects “No”.

Gravity Forms confirmation conditional logic

We can use conditional logic to show different confirmation messages depending on what information the user entered in our form.

So when a user tells us that their favorite type of coffee is a cappuccino, here’s what they’ll see after submitting the form:

A message that says "I also LOVE Cappuccinos! Thanks for taking part in the survey"

But if they check the box that says “Americano”, they’ll see this:

A message that says "Did you know the name 'Americano' comes from the Italian 'Caffee Americano', which means 'American coffee'?"

These are just a few examples of how you can use conditional logic to create a personalized experience for your users. 

How to use conditional logic in Gravity Forms

Now that you know how conditional logic works, let’s look at how you can implement it on your website.

Enable conditional logic to show or hide form fields

Hover over “Forms” in the left-hand menu, click “New Form” and add your desired fields. Next, click on a field that you want to show or hide.

An arrow pointing to the 'Conditional Logic' tab in the Gravity Forms field settings

Under “Field Settings”, click on “Conditional Logic”. The conditional logic settings will open in a new window that slides in from the right-hand side.

Toggle to enable conditional logic and then set your conditions below.

Conditional logic settings in Gravity Forms

Here you can show or hide fields based on one or more user input values.

Enabling conditional logic for Gravity Forms notifications

Gravity Forms allows you to send email messages after a user submits your form. You can use conditional logic to determine which notification to send to a user based on the information they enter in their submission.

Go to the form settings page and click on the “Notifications” tab on the left.

The Gravity Forms Notifications page

Next, edit your existing notification or create a new one.

A notification message in a Gravity Forms notification

After writing your notification message, scroll down to the bottom of the page where it says “Conditional Logic” and check the box to enable it.

Conditional logic settings for Notifications in Gravity Forms

In this example, we’re only sending this notification to users who chose “Americano” as their favorite type of coffee.

Gravity Forms feed conditional logic

You can also use conditional logic for your Gravity Forms feeds.

A feed is a notification that sends information to an add-on or external service when a user submits your form.

External services refer to anything outside of Gravity Forms. This includes CRMs like Salesforce, storage services like Dropbox, and other third-party applications.

Feeds are part of what makes Gravity Forms such a powerful and flexible form plugin. Using conditional logic on feeds gives rise to a whole new set of possibilities.

To create new feeds for your forms, you’ll need to install an add-on that supports feeds, such as the Gravity Forms User Registration add-on.

Example: conditional user registration

You can view your form feeds by going to the form settings. You’ll see different feeds appear in the left-hand sidebar.

In this example, we’re going to create a user registration feed and then conditionally register users on our site depending on what information they entered into the registration form.

If you don’t have a user registration feed set up yet, click Add New.

The "User Registration" feed in Gravity Forms

Configure your feed and then scroll down to the bottom where it says “Registration Condition” and check the box to enable it.

The conditional logic settings for the Gravity Forms User Registration add-on

In this example, we have configured it to only register users with a “” email address.

Conditional logic for product pricing

The Gravity Forms “Product” field enables you to sell products using Gravity Forms. But what if you want to adjust the price of your products based on the order quantity?

You can do this using the Conditional Pricing Perk by GravityWiz. This add-on allows you to create unlimited pricing levels for your Gravity Forms Product fields.

After installing the add-on, create a new form in Gravity Forms, open up the “Pricing Fields” tab and add a “Product” field.

The Gravity Forms Product field

Now update your form, hover over “Settings” and click on “Conditional Pricing”. Choose your product from the dropdown menu and create a new pricing level.

Gravity Perks Conditional Pricing feed

In this example, the regular cost of our product is $15, but we’ve decided to lower it to $10 if the customer orders 10 or more.

So as you can see, with an order quantity of 5 units, the price stays at $15.

A product form showing the "price" as $15.00 and the "Quantity" as 5.

But if the customer changes the quantity to 10, the price automatically becomes $10.

A product form showing the "price" as $10.00 and the "Quantity" as 10.

Using the Conditional Pricing add-on is a simple way to create products with variable prices in Gravity Forms.

Gravity Forms complex conditional logic with the conditional shortcode

Most people are unaware that Gravity Forms includes a conditional shortcode that allows you to conditionally display information based on the values a user enters in their submission.

The basic shortcode template looks like this:

[gravityforms action="conditional" merge_tag="" condition="" value=""]
Content to display.

You can learn more about the Gravity Forms conditional shortcode by reading our guides below:

Gravity Forms conditional logic not working?

If you’ve configured conditional logic in Gravity Forms and it’s not working as expected, it may be due to one of the following reasons:

1. There’s a plugin or theme conflict

The most common reason for conditional logic not working is a plugin or theme conflict. To test whether this is the issue, follow this helpful guide.

2. You have an optimization plugin installed that’s interfering with the JavaScript required to implement the conditional logic

Some WordPress optimization plugins improve page speed by implementing aggressive caching or minifying. This may be causing the conditional logic not to function properly. Disable any optimization plugins and try again.

3. You’re testing the changes from a cached version of the page

If you’re using a caching plugin on your site, clear your cache and then test the changes again.

Gravity Forms advanced conditional logic

You can use the powerful [gvlogic] shortcode to display content based on conditions that you set. The shortcode is added by GravityView, a popular add-on for Gravity Forms that allows you to display your form data on the front end.

[gvlogic] supports more parameters than the [gravityforms] conditional shortcode and it also allows you to restrict content to logged-in users!

You can use the [gvlogic] shortcode anywhere on your WordPress website – This includes pages, posts, Views, widgets, confirmations, notifications, and more!

Other ways to use conditional logic in Gravity Forms

Did you know that conditional logic is a feature of almost every aspect of the Gravity Forms plugin? Here are some lesser-known ways to use conditional logic inside Gravity Forms.

Gravity Forms conditional logic: wrapping up

Personalization and relevant content are two important aspects of running a successful website. Conditional logic is a powerful way to optimize your website forms and create highly targeted content.

In Gravity Forms, you can use conditional logic to hide or display form fields, send personalized notifications, create variable product prices, and more.

If you have GravityView, you can use the [gvlogic] shortcode to conditionally display content on your website based on the information a user enters in their form submission.

You can use conditional logic almost anywhere inside Gravity Forms and GravityView, including form fields, notifications, confirmations, and feeds!