Gravity Forms Conditional Logic: The Ultimate Guide

"Gravity Forms Conditional Logic". The Gravity Forms logo next to an icon representing conditional logic


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: 18 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 is a big part of Gravity Forms. 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.

📝 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 sign-up 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 form with a Name field and a dropdown field that says "Do you drink coffee?" with the answer showing as "no"

But if they select “Yes”, a new field appears asking them whether they prefer lattes, cappuccinos, or americanos.

the "do you drink coffee" now shows as "yes" and another checkbox field is displaying asking "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.

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. If you’re using the Gravity Forms 2.5 or later, 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

You can use conditional logic to determine which notification to send to a user based on the information they enter into your form.

Go to your forms page, hover over your form, hover over Settings, and then click on Notifications.

An arrow pointing to the "Notifications" option under "Settings" for a form in Gravity Forms

Edit your existing notification or create a new one. Now 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 or the GravityView Calendar add-on.

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.

The shortcode accepts the following four parameters:

  • action (always “conditional”)
  • merge_tag (the merge tag for the field value you want to evaluate
  • condition (is, isnot, greater_than, less_than, contains, starts_with, or ends_with)
  • value (the value compared against the value of the merge tag

Here’s how you can use this shortcode to display different confirmation messages to your users.

Example: Conditional Confirmation Messages

You can use the conditional shortcode inside a confirmation, to display a different message to the user depending on the information they submitted.

Go to the forms page, hover over your form, hover over Settings, and click on Confirmations.

An arrow pointing to the Confirmations link under "Settings" for a form in Gravity Forms

Next, click the Add New button in the top right corner to add a new confirmation. You can now use the [gravityforms] conditional shortcode to create a dynamic confirmation message. 

💡 Pro tip: To add merge tags, click the button on the right side of the text editor.

The Gravity Forms Confirmation text editor containing the "gravityforms" conditional shortcode. The button to add merge tags is also highlighted.

In this example, we’re checking what the user’s favorite kind of coffee is and displaying a different message depending on which one they choose.

Nesting Shortcodes

You can nest shortcodes to create more complex conditional logic. Nesting conditional shortcodes in Gravity Forms requires you to use the plural [gravityforms] and the singular [gravityforms].

Here’s what the basic structure looks like:

[gravityforms action="conditional" merge_tag="" condition="" value=""]
[gravityform action="conditional" merge_tag="" condition="" value=""]
Your content

Nesting is helpful if you want to evaluate more than one condition.

Gravity Forms Conditional Logic Shortcode Limitations

While the [gravityforms] conditional shortcode is a good way to dynamically display content depending on the information a user enters in their submission, it’s not without its limitations.

First off, the shortcode can only evaluate the following conditions:

  • is
  • isnot
  • greater_than
  • less_than
  • contains
  • starts_with
  • ends_with

The shortcode does not support “greater than or equals” or “less than or equals”. And while the shortcode supports “contains” it does not support “not contains”.

Furthermore, the shortcode does not support matching values in fields that are JSON-encoded, such as the List and Multiselect fields. 

And finally, the [gravityforms] shortcode only supports two nesting levels, which is a limitation if you need to evaluate more than two conditions.

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:

  • 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.
  • 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.
  • 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

If you have GravityView installed on your website, you can use the powerful [gvlogic] shortcode to display content based on conditions that you set.

📝 GravityView is a plugin that extends Gravity Forms by allowing you to display form entries on the front end of your website.

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

[gvlogic] supports more parameters than the [gravityforms] conditional shortcode and it also allows you to restrict content to logged-in users. Here’s how it works.

Constructing an if/else Statement

Using [gvlogic] you can construct if/else statements that allow you to display content based on conditions that you set. An “if” statement says “if X then do Y, else do Z”.

Here’s what the basic template looks like:

[gvlogic if="{field}" is="Value"]
	Text you want to display if condition is true.
 	Display this instead.

For the “if” parameters, we set it equal to a Gravity Forms field value using a merge tag. “Is” refers to the value we want to compare it against.

If we rewrite the above confirmation using [gvlogic] instead of the [gravityforms] conditional shortcode, here’s how it looks.

The Gravity Forms Confirmation text editor containing the "gv logic" shortcode

As you can see, it only requires a few lines of code. You can display any kind of content using [gvlogic]. This includes HTML, other shortcodes, and more.


One of the reasons [gvlogic] is so powerful is because it accepts several parameters, including:

  • if (Required, unless you’re using the logged_in parameter)
    • The if parameter accepts Gravity Forms Merge Tags
  • logged_in (Required, unless you’re using the if parameter)
  • is or equals (Required if you’re using the if parameter)
  • else

Comparison parameters:

  • isnot 
  • contains 
  • not_contains 
  • starts_with 
  • ends_with 
  • greater_than 
  • greater_than_or_is or greater_than_or_equals
  • less_than 
  • less_than_or_is or less_than_or_equals

As you can see, [gvlogic] supports several comparison parameters that the inbuilt [gravityforms] shortcode does not.

AND/OR Logic

[gvlogic] supports AND/OR logic. This enables you to check a value against multiple other values.

To construct an AND statement use ‘&&’ and for an OR statement, you use ‘||’. For example, here’s how you would check if a field value is equal to either 3 or 4.

[gvlogic if="{Text:3}" equals="3||4"]
Your answer was either 3 or 4

Here’s how you would check whether a string contained both the words “apple” and “orange”.

[gvlogic if="{Text:3}" contains="apple&&orange"]
Your answer contained both apple and orange!

Using Conditional Logic to Hide Content for Logged-out Users

For example, let’s say you had an article that you wanted to restrict to members only. When a new user tries to view the page, here’s what they would see.

[gvlogic] is a powerful and versatile shortcode. You can also use it to show or hide content anywhere on your website. To display content based on whether a user is logged in, use the logged_in parameter, like so:

[gvlogic logged_in="true"]
Congrats! You’re logged in!
You need to log in first before viewing this content.
A message that says "Uh oh! You need to log in before viewing this content."

But when a logged-in user opens the same page, they see this:

A message that says "Congrats! You're logged in! Here's some content..."

To use [gvlogic] on a page or post, copy and paste your code into a Gutenberg Shortcode module.

The WordPress 'Shortcode' block

Checking Multiple Conditions with and

If you want to evaluate multiple conditions using [gvlogic] you can do this using nested shortcodes. [gvlogic] supports three nesting levels using and .


As you can see, the ability to nest multiple shortcodes allows you to create complex conditional logic statements.

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.

Exporting Entries

When exporting entries from Gravity Forms, you can choose which entries to export based on conditions that you set. This is helpful if you have a large number of entries.

Go to the export page, select your form from the dropdown menu, choose which fields to include in your export file and then scroll down to the bottom where it says “Conditional Logic”.

Click Add condition to create a new conditional statement.

The "Add condition" button

Here’s how you would only export entries where the user chose either “Americano” or “Latte” as their favorite type of coffee.

Conditional Logic settings for exporting entries in 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 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!