Best ways to use conditional logic to create killer forms

How to Use Conditional Logic in WordPress Forms (7 Ways)

Do you want to harness the power of a form builder with conditional logic?

Conditional logic lets you set rules on how a form should behave based on the user’s selections and entries. It means you can show and hide fields as needed, send different confirmations and email notifications, and much more.

In this guide I’ll show you how to use conditional logic in WordPress forms, with seven use cases you can copy straight into your own setup.

Add Conditional Logic to WordPress Forms

What Is Conditional Logic in WordPress Forms?

A conditional logic form is a dynamic form that changes based on the user input. For example, a survey form might use conditional logic to show different questions to different users based on their previous answers.

When used correctly, conditional logic is a powerful tool that can improve user experience by only showing form fields most relevant to them.

WPForms calls this smart conditional logic, and it starts at the Basic license. WPForms Lite doesn’t include it, which is worth knowing before you plan a form around it.

The WPForms pricing page.

How Conditional Logic Works in WPForms

Every conditional logic rule in WPForms is built from the same four parts, so once you’ve set one up the rest all follow the same shape.

Click any field in the form builder to open its Field Options panel, then open the Smart Logic tab and toggle on Enable Conditional Logic. You’ll get a row of dropdowns to fill in:

  • Show/Hide: Whether the rule reveals the field or hides it when your conditions are met.
  • Select Field: The field whose answer this rule watches.
  • Comparison: Your options are is, is not, empty, not empty, contains, does not contain, starts with, ends with, greater than, and less than.
  • Select Choice: The value you’re testing against. It deactivates if you picked empty or not empty.

Comparisons aren’t case-sensitive, so you don’t have to match capitalization exactly when you type a value in. One rule handles most situations, but you can stack as many as you need.

Click the And button when two conditions have to be true at the same time, or Add New Group when either condition should be enough on its own. The guide on AND and OR conditional logic walks through both patterns with worked examples.

Conditional logic reaches well beyond form fields, so you can also apply it to email notifications, confirmation messages, marketing integrations on a Plus license, and payment settings on Pro. If you want the complete reference for every option, the conditional logic documentation covers all of it.

Ways to Use Conditional Logic to Create Killer Forms

WPForms is a drag-and-drop form builder with conditional logic built into the core plugin rather than bolted on as a separate addon, so every use case below is set up from inside the form builder you’re already working in.

Use caseWhat it doesWhere you set it upMinimum tier
1. Show relevant informationReveals role-specific instructions and questionsField Options » Smart LogicBasic
2. Survey follow-upsAsks different questions based on a ratingField Options » Smart LogicBasic (Likert needs Pro)
3. Alternate confirmationsSends a tailored thank you messageSettings » ConfirmationsBasic
4. Multi-contact formRoutes each message to the right departmentSettings » NotificationsBasic
5. Lead routingSends leads to the right team automaticallySettings » NotificationsBasic
6. Specific confirmation pageRedirects people based on their answersSettings » ConfirmationsBasic
7. Age-appropriate fieldsShows different questions to different age groupsField Options » Smart LogicBasic

1. Show Only the Most Relevant Information

An easy way to make a big impact with conditional logic is by using it to show the most relevant information. It helps to avoid needlessly long forms.

Here’s an example of a job application form that asks applicants to first select the role for which they’re applying.

select a job role

The rest of the form looks pretty basic, but look at what happens when you select the radio button for one of those positions to apply.

Content Writer Job Details

A brief job description and the requirements that are specific to that position appear. At the bottom of the form, there are role-specific questions that the applicant must answer to apply.

Role-specific questions

How does this happen? Through conditional logic, which can significantly enhance your hiring process. Let’s look at the settings for this form to see how it works.

In the form builder, you can see that the question asking which role interests them is a Multiple Choice field. Next, we’ve used the Content field to add more information about each role.

To make the Content field appear with the instructions for the selected role, just click on the field to go into its Field Options and then select the Smart Logic tab.

From there, you can enable Conditional Logic and create a rule to show the appropriate Content field when a specific role is selected using the Multiple Choices field.

Conditional Logic Setup Job Application

You can add unique instructions for each role by inserting multiple instances of the Content field and then repeating the same process above.

2. Collect Additional Feedback in Surveys

Let’s say you’ve built a super simple customer survey using WPForms. It’s something customers can complete in less than a minute.

Customer Survey

But maybe you want a little more information depending on the kind of rating a user gives. Whether a user gives you a low rating or a high one, it’d be valuable information to learn what you need to fix and what you’re doing well.

We can set up this feedback form so that conditional logic triggers one set of questions if someone answers one way and another set of questions if they answer another way.

To set that up, you’ll go into your form builder and add a Paragraph field with the follow-up question you want to ask.

conditional logic followup question

Since this is a question you’d ask if you get a low score, we’ll set that up as a conditional field. With the field settings open for that question, we click on the Smart Logic tab in the field settings on the left.

Then we use the toggle to enable Conditional Logic and set the rules. We want that rule to say that if the rating field receives a score less than 3 stars (i.e. 1 or 2 stars), the “what could we do to improve?” question will display.

low ratings conditional logic

Next, we’ll set up a similar rule for ratings higher than 2.

conditional logic positive responses

For positive feedback, we’ve created a Likert Scale to ask respondents how satisfied they are with specific aspects of the business. In the field settings for the Likert Scale, we’ve selected the Smart Logic tab at the top.

This time we set the rule to show this option if the rating is greater than 2. This means a rating of 3-5 is considered positive, and those users will see the Likert Scale question appear as soon as they give their rating.

Once satisfied with your conditional logic options, you can publish your survey. Here you see that someone who gives a rating of 3 or above sees the Likert Scale.

conditional logic greater than 2

Someone who rates 2 or below will see the improvement question instead.

conditional logic 2 or below

The survey is still very simple, but conditional logic means that users will only see the information that’s most relevant to them.

Tier note

The Likert Scale and NPS fields come with the Surveys and Polls addon, which needs a Pro license. The conditional logic driving them is available from Basic up.

3. Set Up Alternate Confirmations

On every form you create with WPForms, you can set up a default confirmation response. After every form submission, then, the user will receive that response.

But what if you want to use different confirmations based on the information the user provided on the form?

That’s when you can use conditional logic to set up alternate confirmations. It’s easy to do with our user-friendly online form builder.

Let’s walk through an example in which we’re going to create an alternate confirmation that will only be sent to users who indicate that they have billing questions.

With your form open in the WPForms form builder, click Settings » Confirmations in the lefthand menu. At the top, click on the Add New Confirmation button.

add new confirmation

Next, you’ll need to give your new confirmation a name. Users won’t see what you name it. It just streamlines your internal workflows.

enter a confirmation name

Once you’ve named the confirmation and confirmed it, a new confirmation appears above your default. In our example, we’ve created a new billing confirmation for users who indicated on the form that they have billing questions.

billing confirmation message

You can see that we’ve tailored the message to let customers know what to expect once they’ve submitted the form.

Next, we’re going to set up the conditional logic. To do this, you need to set the toggle button next to the option to Enable Conditional Logic.

enable conditional logic

When you do that, you get options for when to send this specific confirmation. The field types you see will depend on what’s on your form.

We want this confirmation to go to users who indicated on the corresponding contact form that their question is about billing.

conditional logic confirmations complete

Save the form and this confirmation message will go out to everyone who meets the criteria you’ve set up.

You can add as many confirmations and conditions as you need, and the conditional form confirmations guide covers the other confirmation types you can trigger this way.

4. Create a Multi-Contact Form

Building off of our last example, what if you could set up your form so notifications always reached the right people?

Instead of one inbox receiving all messages, billing questions could go to billing, sales questions could go to sales, and so on.

Rather than creating new forms for every department, you can make that happen with conditional logic. First, you have to make sure there’s a field on your form to let users indicate where they want to direct their questions.

An easy way to achieve that is with a dropdown list.

multi-contact form

This field will be the basis for your conditional logic settings and tell the form where to send each message.

With your form open in the WPForms form builder, click Settings » Notifications in the lefthand menu. At the top, click on the Add New Notification button. When you do that, you’ll get a prompt to name your notification.

In this case, we want to notify the billing department when someone has a billing question, so we’ll call it that. The name is just for your organizational purposes and isn’t public.

new billing notification

When your new notification is set up, the first thing you can do is enter an email address for that notification. In our example, we used a billing email address since it’s for billing questions.

You can also adjust any of the other form fields if you like.

billing notification setup

Below the last notifications field for the Email Message, you’ll find the toggle switch to enable conditional logic. Once you do that, you can set the conditions.

In our example, we want to notify the billing department when someone indicates on our contact form that they have a billing question.

We can also customize the email message to match the nature of the inquiry.

conditional logic enabled

That’s all there is to it. You can add a new confirmation message for every department corresponding to your contact form and use conditional logic to make sure the right team always gets the message.

5. Set Up Lead Routing

Using a similar process to the multi-contact form setup above, you can also set up lead routing with conditional logic. Let’s say you have a form that you’re using to capture leads on a landing page or popup on your site.

lead capture form for routing

You want the right team to receive the lead based on the response. To get started, follow the steps from the previous example with the multi-contact form.

Go to Settings » Notifications, and click on Add New Notification. In the case of our form, we will need 3 notifications to route the leads. Let’s start with sales.

sales notification setup

Ensure the Send To Email Address field contains an email address for your sales team. Next, you’ll enable conditional logic at the bottom of your new notification.

Enable notification conditional logic

Repeat those steps for each lead type on your form, and know that the message will always get to the right team. Customers and prospects will love the reduced response time!

6. Send Users to a Specific Confirmation Page

Suppose you have a survey form where users can indicate their interest in joining your organization or getting more information.

A checkbox to indicate interest in membership

In that case, a specific confirmation page can direct them to more information or resources.

Once again, we’ll get started by going to Settings » Confirmations » Add New Confirmation in your form settings. Give your new confirmation a name.

Entering a new confirmation name

The default confirmation is a message, but if you want to send users to a specific page, you’ll need to change that confirmation type setting.

Show Page Option

After you change the confirmation type to Show Page, you’ll be able to select which page from your WordPress site you want to use for the confirmation page.

After enabling conditional logic, you can configure the settings. In this example, we want the user to land on this confirmation page after selecting the checkbox on the form saying that they’re interested in learning more about becoming a member.

Show Page Conditional Logic

After you save those settings, all users interested in learning more will be redirected to a landing page letting them know what comes next.

Confirmation Page

7. Show Age-Appropriate Form Fields

You might sometimes find that not all of your form response options are age-appropriate for everyone who might respond. One use case we can look at is our reading program book log form template.

Because you ask kids and adults different questions about their books, we needed to set up different questions. One of those was whether there were any content warnings they’d give people before they read a particular book.

That’s not a question that will apply or make sense to children, so we can apply conditional logic so that it only displays when someone selects either the teen or adult program.

Setting up CL

When the form is live, you can see that when the children’s program is selected, the form is very basic and something parents can easily ask their children and fill out.

kids form example

But when the adult program is selected, the form becomes more complex.

adult program survey example

And that’s it! Now that you know how to use conditional logic in different ways, you’re ready to create killer dynamic forms for your users.

Every one of these seven examples runs on the same four dropdowns from the start of this guide, which is the part worth remembering. Once the rule builder makes sense, each new use case comes down to deciding which field the rule should watch.

FAQs on Conditional Logic in WordPress Forms

Conditional logic comes up a lot once people start building forms with more than a handful of fields. Here are the questions I get asked most often about using conditional logic in WordPress forms.

What is conditional logic in a WordPress form?

It’s a set of if/then rules that change your form based on what someone selects or types. The rules can show or hide fields, decide which email notification goes out, and control which confirmation message or page the person sees after they submit.

Do I need WPForms Pro to use conditional logic?

No. Conditional logic is included from the Basic license up, and that covers fields, notifications, and confirmations. You only need Pro for conditional logic on payment settings and for the addons that some of these examples use, like Surveys and Polls.

Is conditional logic available in WPForms Lite?

Lite doesn’t include conditional logic, so forms built on the free plugin can’t show or hide fields based on user input. Basic is the entry point for it.

Can I use AND and OR logic on the same field?

Yes. Use the And button to require several conditions at once, and Add New Group to create an alternative set of conditions that works on its own. Mixing both lets you build rules like “show this field if the rating is 5 and they agreed to leave a review, or if they picked the enterprise plan.”

Can conditional logic hide an entire page in a multi-page form?

It can. Conditional logic applies to page breaks and whole sections, not just individual fields, so you can skip past an entire step for people it doesn’t apply to. Multi-page forms are available from Basic up.

Does conditional logic work with payments?

On Pro it does. Stripe Pro, Square Pro, and the PayPal Commerce addon all support conditional logic, so you can change what someone is charged or which payment option appears based on their answers. The payment integrations available in Lite and Basic don’t include conditional logic on payment settings.

Next, Send Your Smart Form Data Where It Belongs

Now that your forms only collect what’s relevant to each person, the next thing worth setting up is where all that data ends up.

The Google Sheets addon for WPForms sends entries straight into a spreadsheet as they come in, and it accepts conditional rules of its own so you can filter which submissions get added.

If you’d rather push data into tools without writing any code, you can also connect WPForms to various third-party apps with Uncanny Automator.

Build Smarter WordPress Forms Now

Ready to build your form? Get started today with the easiest WordPress form builder plugin. WPForms Pro includes lots of free templates and offers a 14-day money-back guarantee.

If this article helped you out, please follow us on Facebook and Twitter for more free WordPress tutorials and guides.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPForms is funded, why it matters, and how you can support us.

Renee DeCoskey

Renee DeCoskey has been blogging since 2001 and using WordPress since 2007. When she's not writing about WordPress plugins, you can find her curled up with a book or having fun in Rotary. Learn More

The Best WordPress Drag and Drop Form Builder Plugin

Easy, Fast, and Secure. Join over 6 million website owners who trust WPForms.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

This form is protected by Cloudflare Turnstile and the Cloudflare Privacy Policy and Terms of Service apply.