How to Build a WordPress Multi-Step Form With Conditional Fields
Your form keeps growing, with one set of questions for new customers, another for regulars, and a quick question from everybody else. So why is every visitor clicking through every page, even when an earlier answer makes a whole step pointless? And can a WordPress multi-step form with conditional fields even work, or does one half break the other?
Maybe you’ve tried hiding fields one at a time, only to end up with an empty page that still shows its title and still wants a click on Next. Search around and you’ll find a tutorial on conditional logic, a separate one on multi-step forms, and not much on making them work together. Meanwhile every extra page is one more place for someone to give up and close the tab.
Yes, it’s a bit of a puzzle the first time. But it’s also a lot simpler than it looks. Below, you’ll build a conditional multi-step WordPress form that skips whole steps based on one answer, with one rule per step and no code at all.
What you’ll need
- Ninja Forms (free)
- The Multi-Step Forms add-on (standalone, or included with memberships)
- The Conditional Logic add-on (standalone, or included with memberships)
Multi-Step Forms splits your form into steps, and Conditional Logic decides which of those steps each visitor sees. Both sell standalone. The Plus membership includes both of them plus more than a dozen other add-ons, and is probably the better buy.
How a WordPress multi-step form with conditional fields skips a step
In Ninja Forms, you split the form into parts with Multi-Step Forms, then give each optional part one conditional logic rule. The rule shows the part when the visitor picks the matching answer and hides it when they don’t. A hidden part disappears from the route completely, title, breadcrumb and all, so the visitor never lands on it.
We built a little example to walk through: a service request form for an axolotl tank care business. It has four steps, About You, New Tank Setup, Maintenance Visit, and Final Details. One dropdown on the first step, “What can we help with?”, decides the route:
- New tank setup goes to New Tank Setup, then Final Details.
- Maintenance visit goes to Maintenance Visit, then Final Details.
- Just a question skips both and goes straight to Final Details.
Only need to hide a few fields on a single page? You don’t need steps for that, and our guide to conditional logic in WordPress forms has you covered. And if your real goal is getting more people to finish a lead form, build a multi-step lead form instead.
Split the form into steps, with the deciding question up front
Everything starts with the fields in your WordPress form. Put the question that decides the route on the first step, because a step can only be skipped once the visitor has answered it.
Give that question a blank first choice, like “Select one.” Without it, a real answer is already selected when the page loads, and your rules fire before the visitor has picked anything.
- Open your form on the Form Fields tab and click the blue (+) icon to open the Fields window, then add your fields.
- Add a blank first option, such as “Select one,” to the deciding question.
- Click the last step’s tab along the bottom of the builder, then click the grey (+) circle on the right edge of the builder to add a new part.
- Click a part’s tab to open it and type the title visitors will see.
- Drag each field onto the tab of the part it belongs in.
- Keep the Submit button on the last part.
That’s all there is to it. If you get stuck, the Multi-Step Forms documentation walks through adding and moving parts in more detail.
Show visitors where they are with breadcrumbs and a progress bar
Before you start hiding steps, give visitors a map. Breadcrumbs and a progress bar tell people how far they’ve come and how far they have to go, and both update as steps drop out of the route.
- Click into the Advanced tab.
- Click Multi-Part. The add-on is called Multi-Step Forms, but its settings live under this name.
- Switch on Show Breadcrumbs and Show Progress Bar.
- Switch on Show Part Titles.
- Switch on Validate Each Part.
Validate Each Part is the one that keeps people honest. With it on, a visitor can’t click Next past a required field they left empty; they stay put and see “This is a required field.” under it. You can also rename the Previous and Next buttons here with the Previous Button Label and Next Button Label settings.
Now for the fun part.
Skip a whole step with one Show Part and Hide Part rule
Each optional step gets one rule, and every rule watches the same question: show this part when the answer matches, hide it when it doesn’t. Got three or four optional steps? Add one rule per step and it works the same way.
- Back in the Advanced tab, click Conditional Logic.
- Click Add New Condition.
- Under When, pick “What can we help with?”, then Has Selected, then New tank setup.
- Under Do, open the first dropdown and choose New Tank Setup from the Parts group, then choose Show Part.
- Under If the Condition Is Not Met, click the blue (+) icon and add New Tank Setup again, this time with Hide Part.
- Click Add New Condition again and build the same rule for Maintenance visit and the Maintenance Visit part.
- Click Done, then Publish.
Notice there’s no rule for “Just a question.” It doesn’t match either rule, so both middle steps stay hidden and that visitor goes straight from About You to Final Details. You get that route for free.
Go ahead and mark the fields inside your optional steps Required, just like you normally would. When a step is hidden, its required fields don’t stop the form from submitting.
Worried about visitors changing their minds? No worries: if they go back and change their answer, the route changes with them. That’s what the Hide Part line in each rule is for.
Keep every visitor on track when the route changes
Skipping steps is a kindness to your visitors, as long as nobody gets lost along the way. Someone using a screen reader or a zoomed-in page can’t glance ahead to see what just changed, so tell them in words. A few habits cover most of it:
- Say up front what the form will ask. Our axolotl form opens with an HTML field: four short steps, and we skip any that don’t apply.
- Keep progress visible on every step. With breadcrumbs and the progress bar on, a hidden step drops out of both, so visitors only see the steps on their own route.
- Reveal a step right after the question that reveals it. With this setup that happens on its own, because the revealed step is always the next one.
- Say when an answer changes what comes next. The deciding question’s Description setting reads “Your answer decides which step comes next.”
- Never ask twice. Name and email live on the first step, so Final Details doesn’t ask for them again.
For more ideas, the W3C’s tutorial on multi-page forms is a friendly read, and a form that’s easy to follow is one more people finish.
Test every route before real visitors do
A conditional WordPress form has more than one way through it, so walk every one of them yourself. It takes two minutes, and it’s a lot less stressful than finding a broken route in your inbox.
- Open your form with Preview Form, or on a page where it’s published.
- Pick New tank setup, click Next, and check that you land on New Tank Setup.
- Click Previous, switch to Maintenance visit, and click Next again.
- Start over with Just a question and check that you go straight to Final Details.
- Submit once on each route and look for the entry under Submissions.
Don’t worry if the progress bar sits at 50% or 67% on the last step. It shows where the visitor is, not what they’ve finished, and it only counts the steps on their route.
Give every visitor a shorter route through your form
Like we said at the top, nobody wants to click through a page that has nothing to do with them. Now your WordPress multi-step form with conditional fields asks one question and sends each visitor down the route that fits, with a quick question going straight to the end. Skip whole steps rather than hiding fields one by one, and your form stays short for everyone who fills it out.
In Ninja Forms, Multi-Step Forms splits your form into steps with breadcrumbs and a progress bar. Conditional Logic decides which of those steps each visitor sees.
Ready to stop making everyone read every page? The Plus membership puts both add-ons in your hands, along with more than a dozen others, so pick it up and build your first shortcut today.
Try Ninja Forms Today
Always free, with premium features available through our memberships.
This is good functionality, but there needs to be a way in which you can hide/reveal entire forms.
No reply so far, but this is what I was looking for, too.
I need to have a “Select” element with at least 3 options and depending on the option, special form should be shown. This works for me for 2 options so far (“selected option 1” / “not met”) but not for three or more options and it means a long list of fields with hide and show for both.
Is there a better way that I don´t see as a new customer?
Hi Ralph
Thanks for reaching out, and for joining the Ninja Forms community.
We are happy to help, but can you please reach out to us via our contact form for support. We’ll be happy to help.
Don’t forget to include a System Status report and an exported copy of the form having issues even though it sounds incomplete.
Thanks!
Mia
Is there a way to do this by grouping form elements within the same page (e.g., Group 1: Name, Gender, Meal Options checkboxes, Group 2: Name, Gender, Meal Options checkboxes) and then revealing those based on conditional logic on a number of guests drop-down?
Or do we have to create separate parts of the multi-form based on the maximum number of guests (e.g., if 15 max, then 15 separate parts)?
@Eric Parkinson,
I’m trying to solve the same problem. I have 10 repeating field sets, and using the method in the guide would either crash the form or make the conditional events not fire.
I’m having the same issue, I have a multi part form and using conditional logic I’m experiencing lagging and conditional events sometimes not firing.
Hello,
How can I hide the pages after submit.
The idea will be that the client can see only the successfully message.
Thank you.
Hi Emily, if you have extra content within the page that you would like hidden after the form is submit by the user, use the paragraph text, single line text, or image form fields and wrap the content as a part of the form. In this way, once the form is submit, the user will only see the success message on submission. I hope this helps!
Is there any way to check for data in another system and present the form depending on the answer?
Example:
Send a webhook to system X and check if the email already exists, and if it does, pop a form that says “This email is already in use” and if it is not used, just proceed with the form.
I’ve split my form into different parts, with the expectation that a customer will select an option and it shows them the next step depending on what they selected. The issue comes in with the required fields. I have required fields on each part of the form, including the ones that end up being hidden. To complete the form though, it still forces the customer to fill out the required fields for the hidden parts, which no customer will figure out on their own, and isn’t ideal. Is there a way to make required fields required as long as that option is selected, but unrequired when that option is not selected/deselected?
I have no coding experience, so would be grateful for any support.
Hi Rob,
Required fields, if hidden, will not be treated as required. Instead of marking the field required in the form, you can set it to be required using conditional logic. If you need any further help, please reach out to us at https://ninjaforms.com/contact/.
I am a bit confused about if this is what I need – Logic & MultiPart or just the Logic. I want to display 3 different text fields based on the user’s selection from two drop-down select fields. The form isn’t getting submitted – I am using it to display options based on the choices from the two drop-down select fields.
Hi Eric,
if you have a single-page form and you only want to dynamically change the form fields that display on the form you only need Conditional Logic. If you have a multi-step form that consists of multiple pages (parts) and you want to show or hide entire groups of form fields on a specific step of your form, you need both of the add-ons.
Hi, I think there’s a typo in this article. In the original conditional logic page, it says to only use “IF CONDITION IS NOT MET” with parts, not fields: https://ninjaforms.com/docs/conditional-logic/
This blog post says the opposite for some reason. Can you confirm which version is correct?
Great catch! The blog post has been updated to reflect the Conditional Logic documentation. 🙏🏼