Skip to content
WordPress Guide

Conditional Logic in WordPress Forms: Show the Right Fields

Conditional logic lets a form ask only the questions that apply and send each enquiry to the right person. Here is how to plan the rules, set them up and test every route.

A desk with website wireframes, a phone and coloured pens
9 sections · 7 min read
In this article · 9 sections

Picture a home-services form that asks every visitor for the make and model of their boiler, including the people who only want a quote for a new bathroom. They either skip the question, type “n/a”, or give up. The fix is to ask the boiler question only when someone has picked boiler repair. That is conditional logic in WordPress forms: fields, emails and messages that change depending on what the visitor has already answered.

It sounds technical, but in the main form plugins it is a set of plain rules you pick from dropdowns. The harder part is planning the rules and then testing every route through the form, and that is where most of this post goes.

What conditional logic can change

Every rule follows the same shape: “do this” if “that field” “is” (or “is not”) “a given value”. Depending on the plugin, you can use rules to:

  • Show or hide a field. The most common use. “Show Boiler make if Service is Boiler repair.”
  • Show or hide a whole section, such as a group of fields or a step in a longer form.
  • Send the notification to different people, so sales enquiries reach one inbox and support requests another.
  • Change the confirmation, showing a different message or thank-you page depending on the answer.

Most plugins also let a rule depend on several conditions at once, with a choice of “all of these” or “any of these”. Start with single conditions. They are far easier to reason about.

Which form plugins can do it

WPForms, Gravity Forms, Fluent Forms, Formidable Forms and Ninja Forms all offer conditional logic in some form, though not always in every version, so check the plugin’s documentation against the version you run. In WPForms the option is called Smart Logic and sits on each field’s settings. In Gravity Forms and Fluent Forms it is labelled Conditional Logic, usually among the field’s advanced options.

Contact Form 7 does not include it. A separate add-on, Conditional Fields for Contact Form 7, adds show-and-hide groups. It works, but it means another plugin to keep updated, and routing notifications still needs extra effort. If you are choosing a plugin partly for this feature, the post weighing Contact Form 7 against WPForms sets out the trade-offs.

Plan the rules before you open the builder

The planning is the part people skip, and it is the part that decides whether conditional logic in WordPress forms saves you time or creates confusion. Write every route through the form on paper or in a spreadsheet first. For each answer to the deciding question, note which extra fields appear and who should receive the enquiry. A small table is enough:

If “Service” is Show these fields Notify
Boiler repair Boiler make, Age of boiler, Is there hot water? Service desk
Bathroom refit Room size, Preferred start month, Photos Sales
Something else Tell us more Sales and service desk

Two things fall out of this exercise. You can see how many routes need testing, and you usually notice a gap, such as an option nobody planned for. The “Something else” row matters: without it, an unusual enquiry can end up with no extra fields and no clear owner.

Base rules on fields with fixed choices, such as dropdowns, radio buttons and checkboxes. A rule like “show this if Message contains urgent” depends on how people type, and they type in every way imaginable.

Setting up conditional logic in WordPress forms

  1. Add every field first, including the ones that will be hidden. A rule can only point at a field that already exists.
  2. Open the field you want to control and find its conditional or logic settings.
  3. Turn the logic on and choose whether the field shows or hides when the rule matches.
  4. Pick the deciding field and the value, for example Service is Boiler repair.
  5. Repeat for each dependent field, or put related fields in a group or section and apply one rule to the group if your plugin allows it.
  6. Save, then preview and click through each choice to watch the fields appear and disappear.

Required fields that may be hidden

If a hidden field is also marked as required, what happens next matters. Most form plugins skip the required check for fields that are hidden by logic, which is the behaviour you want. If yours does not, visitors on the other route will be told a field is missing that they cannot even see, and the form will never submit. Test this specifically for every required field that has a rule on it.

Answers that change halfway

People change their minds. Someone picks Boiler repair, fills in the boiler details, then switches to Bathroom refit. Plugins differ in whether the now-hidden answers are dropped or still sent with the entry. Try it on your form, and look at what arrives in the email and the stored entry, so a bathroom enquiry does not arrive carrying stray boiler details.

Sending the enquiry to the right person

Routing is where conditional logic saves real time. Instead of one inbox that someone has to sort, each enquiry lands with the person who can answer it. The usual setup is one notification per destination, each with a condition attached: send this one when Service is Bathroom refit, that one when it is Boiler repair. Gravity Forms also offers a routing option inside a single notification.

The mechanics of recipients, copies and reply-to addresses are covered in the post on form notification emails. One safety rule belongs here: keep one notification that always goes to a main inbox, or make sure every possible answer is covered by a rule. Otherwise an option you add next year may send its enquiries nowhere.

Test every route, not just the first one

A form with three answers to its deciding question has at least three routes. Add a second rule-driven question and you can quickly reach six or nine. Each route needs one real submission, checked from start to finish:

  • the right fields appeared and the wrong ones stayed hidden;
  • the form submitted without a phantom “required” error;
  • the notification reached the intended inbox, and only that one;
  • the stored entry and the email contain the answers you expect;
  • the correct confirmation message or page appeared.

Label each test clearly, for example “TEST bathroom route”, so nobody acts on it. If the form is busy, build and test the rules on a staging copy of the site first. A full routine for checking forms after any change is in our post on how to test WordPress forms.

Mistakes that quietly break the rules

  • Editing dropdown options later. Rules often match the exact text or value of a choice. Rename “Boiler repair” to “Boiler service” and the rule may stop matching without any warning. Recheck the rules whenever you edit options.
  • Deleting a field that others depend on. Rules pointing at a removed field can fail silently or behave oddly. Check what depends on a field before you delete it.
  • Hiding the email or phone field. If a rule can hide your only contact field, you can end up with enquiries you cannot answer.
  • Chains of rules. Field C depends on B, which depends on A. Each link multiplies the testing. Keep chains short.
  • Making the form longer, not shorter. Conditional logic should remove irrelevant questions, not justify adding more.

Where this fits with other form work

Conditional logic decides which questions appear. Breaking a long form into screens is a separate job, explained in building a form with steps, and the two often work together. For the wider picture, including choosing a plugin and making sure entries are delivered, start with our guide to WordPress forms. It sits within the WordPress site owner’s handbook, which covers the rest of looking after a site.

Frequently asked questions

Does a hidden field still appear in the notification email?

It depends on the plugin and the setting. Many plugins leave empty or hidden fields out of the email, while others list every field with a blank value. If your notification uses an all-fields tag, submit a test on each route and read the email that arrives, so you know what your staff will see.

Will conditional logic work if a visitor’s browser blocks scripts?

Showing and hiding fields happens in the visitor’s browser using JavaScript. If scripts are blocked or fail to load, behaviour varies: the visitor might see every field, or the form may not work properly. A plugin or optimisation setting that delays scripts can cause the same problem, so test after changing caching or speed settings.

Can conditional logic make a form harder to use with a screen reader?

It can if fields appear somewhere unexpected. Keep revealed fields directly after the question that triggers them, so they come next in reading order, and give them clear labels. Avoid revealing fields above the current one, and try the form using only the keyboard to check that the order makes sense.

When does a form have too many rules?

Plugins rarely set a practical limit, so the real limit is your own patience. Every rule adds routes to test and something to recheck when the form changes. If a form needs dozens of rules, it may work better as two or three separate forms, each linked from the page where that kind of visitor arrives.

Rules added a few at a time over the years can become hard to read back. Our WordPress support service can go through the routes with you, tidy the rules and test them, with a backup taken before anything changes.

Next in this series: How to Add a Newsletter Signup Form in WordPress

Is Your Website Working Properly?

Get a free website health check from WebMaintor. We'll review your website's speed, security, forms, and technical health — and tell you exactly what needs attention.

No obligation. No automated reports. A real review by our team.