If you are searching for WordPress forms that support conditional logic, Ninja Forms got your back with easy-to-follow conditional logic functionality! And as much as it might seem scary and troublesome to create conditional logic forms in WordPress, it does not require a lot of work, and you don’t need any coding skills or developer.
Today, you will become a master of conditional logic and you will learn to do the following:
- show or hide fields based on how someone responds to the other form fields on your form
- skip to a different page if you are using multi-step forms
- add multiple payment options to your WordPress payment forms
We will also show you how to:
- send contacts to different email lists using our email integrations and conditional logic add-on
- create conditional actions including sending email notifications or email confirmation receipts to specific people, conditional redirects, and displaying customized messages after submitting the form
So sit comfortably, and join us on this reading journey where we will show step-by-step how to use conditional logic in WordPress forms without losing your mind. Streamlined forms and happy visitors are guaranteed!
Table of content
- How to make a conditional logic form in WordPress
- How to dynamically show or hide form fields based on a user’s response
- How to create conditional actions in WordPress (send a conditional email, conditional redirect, a customized success message, record submission if conditions are met)
- Signup new users to a different newsletter (or CRM) list
- How to use calculation and conditional fields in WordPress forms
- Allow users to select a payment method in WordPress form
1. How to create a conditional logic form in WordPress
As much as conditional logic might sound scary, it’s effortless to create WordPress conditional forms with our contact form plugin. All you need to get started is 2 things:
- Free Ninja Forms core plugin (download here)
- Conditional Logic add-on (included in all memberships/can be purchased individually)
Step 1. Install and activate Ninja Forms
First, install the Ninja Forms free core plugin by navigating to your WordPress Admin Menu, clicking Plugins > Add New. Locate the Search Plugins field, type “Ninja Forms,” then click the Install Now button and Activate.
Otherwise, you can upload the plugin by navigating to Plugins > Add New > Upload Plugin > Choose File.
Step 2. Install and activate the Conditional Logic add-on
Once you have access to the Ninja Forms conditional logic, you can download it from your Ninja Forms account, and upload it to Plugins. For a complete overview, see our installation guide for step-by-step instructions.
If you successfully follow the installation instructions, you should see the Conditional Logic tab under the Advanced tab of the Ninja Forms form builder.
If you don’t, make sure to enable the Developer Mode in your Ninja Forms settings. You can learn how to enable Developer Mode here to unlock advanced settings on your Ninja Forms.
You will also see the Conditional Logic section in each new action available under the Emails & Action tab. Here is where you can create conditional actions such as sending conditional emails, displaying customized text after the user submits the form, redirecting the user to a different landing page, or saving the submission entry if specific conditions are met.
Ninja Forms conditional logic can be used along with other Ninja Forms add-ons. We will talk about it later in this article.
Now that we showed you where you can find the conditional settings on your form, let us show you practical examples of when and how to use form logic to make your forms more simple and personalized so the user will only see what is relevant to him.
2. How to dynamically show or hide form fields based on a user’s response
Using our Conditional Logic add-on, you can create a dynamic form and tell any given form field on the form to display/hide based on a user’s interaction with any other form field.
This functionality on your forms saves your visitors time and delivers better UI making your forms faster. This means more completed forms and less form abandonment.
Let’s look at our example below. You can see how certain fields are hidden for users, who select option No. On the other hand, when users select the option Yes, the content will change dynamically and another Radio list of options will appear.
In order to set this up on your form, you want to first create form fields with your options using the Radio list field. Make sure the Value of your form fields is filled out.
Then you’ll want to head to the Advanced tab and select Conditional Logic. Here you can add conditions for your form fields just like we did in order to hide meal options in the case user selects the option No in the first place as shown on the screenshot below:
That’s it! You’ve just learned how to create dynamic fields and show the fields based on the user’s input on your form.
Hide and display list options, or pre-select them conditionally
Any list field option can be hidden or displayed in Ninja Forms using Conditional Logic. You can show/hide submit button if you don’t want all users to submit your form or if you want to disable specific users to submit their submission entries due to spam.
Another popular way to use conditional logic with your fields is by offering a custom response on your form. Let’s say your user does not choose a specific answer from multiple choices and chooses the option Other. You want to collect more data than just “Other” so, in order to let your visitors write their personalized answers, you can use a Single Line Text field.
Let’s assume, you created your Radio List field and Single Line Text field on your form. Now head over to Conditional Logic under the Advanced tab and set up the conditions as below:
This is what it will look like in your form preview:
Similarly, you can have list options conditionally selected or deselected for the user without requiring their interaction. Just create a logic statement that’s based on earlier user interaction with the form.
Please note, that your conditional trigger options will change based on the form field types. As you can see from the screenshot below, the options are not the same for Single Line Text Field as they are for Radio List Field.
Show and hide the entire page on a multi-step form
Above, we showed you can easily set WordPress form logic to target form fields. The same logic can be applied to entire steps/pages of your form if you’re using Multi-Step Forms. You just use conditional logic statements on the individual pages instead of (or in addition to) fields.
Using our free Ninja Forms core plugin and Conditional Logic add-on, you can show or hide pages of multi-step forms with unnecessary form fields based on the user’s input on the form. All you need is to break your groups of form fields out into sections and apply conditional logic to the sections rather than individual fields. Here’s what the form will look like broken into parts:
Now that we have our field groupings/sections in place, you’ll want to apply the Conditional Logic add-on. Here’s an example conditional that will hide Guest 2 Food Order and Guest 3 Food Order parts if the invitee selects one guest:
if you would like to see a step-by-step article on how to hide or display entire pages on your multi-step form, you can visit our article to get into the specifics.
As you can see, using conditional logic help you streamline your forms and save visitors from a lot of frustrations. Your form visitors don’t want to waste their time filling fields or groups of fields that are not relevant to them, and you probably don’t want to lose valuable submissions.
The Conditional Logic add-on is the perfect solution to streamline your WordPress forms and make sure your visitors are completing them.
3. How to create conditional actions in WordPress
Have you ever wanted to send conditional emails in WordPress to notify only specific people via email? Need to display a customizable message after the form is submitted? Want to offer different lead magnets or redirect users to different landing pages? You can do all of this easily using conditional logic.
1. How to send conditional email in WordPress
Not every form submission needs to be sent to the same people internally. So, if you want to send an email notification to a specific department, conditional logic comes to the rescue. You can have any number of email actions set up on any form with Ninja Forms. If you need to send email notifications to multiple departments based on user selection on the form, you would create an email notification for each department.
Here is an example how you would set up a conditional email on your form:
In our form, we are asking the user to choose the service from 4 options. We use the Radio list field type where each option represents the department. Based on which option the user selects, the right department will be notified by email.
This is how you want to set up your Email action:
First, you create as many email actions as the number of options by simply duplicating the Email action. As we have 4 different options in our form, we need to create four different email actions. Each email action has to have the “To address” set for the department that needs to receive the email if this option has been selected by the user.
That’s it! If you would like to dive deeper into sending conditional emails, you can check our additional resources: How to Send Conditional Email from WordPress, Send Conditional Email with Ninja Forms, or Getting the Right Notifications to the Right People: A Tutorial.
2. Send users to different landing pages or forms automatically
Combining conditional logic with our Redirect action, you can offer a personalized experience for your visitors and send users to a different URL or a form. You can trigger an action that directs users to different landing pages based on the user’s specific entries on their WordPress form.
Just like you applied logic to using an email action, Redirect action works the same way. For each select field option, you need to create an individual Redirect action.
Let’s say you are making a quiz asking users what is their preferred vacation spot. First, you set up a radio list to give them options between the mountains, beach, and city. Depending on the options you defined in your form and which option your users choose, you can send them to the page of their interest.
Once your form is ready, head out to the Emails & Actions tab and create a Redirect action for each option (mountains, beach, city). This is how your Redirect action will look like if your user selects the option Mountains:
In the URL field, you enter the website where you want to redirect your users. You can set up the other Redirect actions with the same logic as shown in the picture above for the rest of the options. Most importantly, make sure your conditions match the proper actions.
3. Offer different lead magnets to different users in the same form
Not everyone is going to respond the same to the same incentive. Common sense, right? But it can get really complicated to try and offer different lead magnets from the same form. It’s actually very easy with our form logic.
In our simple demonstration, we’ll show you how to display different success messages based on users’ input on the form. You’ll always want to keep in mind that 1 Success Message Action = 1 User Selection. If you have two options in your select field, you would set up individual actions for option 1 (Learn WordPress), and option 2 (Learn HTML Quickly).
You can customize each Success Message action using the Summernote WYSIWYG editor integrated into Ninja Forms. You can insert images, links, tables, and merge tags for better personalization. If you would like to learn more about the editor, you can check our super easy tutorial How to Easily Customize Your Ninja Forms Email!
4. Signup new users to a different newsletter (or CRM) list
Do you have multiple lists in your email marketing account but don’t want to sort your contacts manually? Conditional Logic can save you hours of manual labor and automatically categorize your new signups to the list of audiences of your choice.
We offer multiple email marketing integrations but we will show you an example with our Mailchimp add-on and conditional logic. First, you need to create a list selection using our Radio/Checkbox/Select field based on which users will be transferred to the correct audience/list.
Second, you want to make sure every list is assigned correctly to your action along with conditions. If you are having multiple email lists, you have to create multiple Mailchimp email actions for each list. See the example below:
If you want to send users to the list Promotions, you need to select the Promotions list. Once you have your existing list, your List Field mapping section will display fields. Here you can map the proper fields, so the data is sent to your Mailchimp account correctly.
Just remember, you’ll want to create for each list/audience an individual Mailchimp action. That’s it! After following the steps, your new signups will be automatically categorized to the list or audience of your choice!
5. How to use calculation and conditional fields in WordPress
Are you looking to build a quote request form that includes values that may vary depending on the way other questions have been answered? Do you want to modify the total amount on your form based on the coupon code you offer?
Maybe you created a quiz and want to display a custom message with a different calculated score? This and much more can be accomplished using conditional logic with our free calculations feature.
In our example below, we will show you how to use our calculation feature along with conditional logic to offer a discount using a coupon code and change the value of the total field. You’ll first need to create 3 fields:
- Coupon Code. This is a Single Line Text field. Customers enter the coupon code here.
- Discount Rate. This is a Hidden field that will contain the discount value.
If you’re offering a percentage discount, set the Default Value to 1. For a flat discount, set the Default Value to 0. In our example, we are offering a percentage discount. - Total. This is an HTML field. However you’re currently handling your total price, you’ll need to use an HTML field to do this.
This setup will vary slightly if you’re offering a percentage or a flat discount.
- If you are offering a percentage discount, you need to MULTIPLY your Product field times your Discount Rate field.
- If you are offering a flat discount, you need to SUBTRACT your Discount Rate field from your Product field.
Our demo demonstrates a percentage coupon code, so we’re multiplying the two fields:
Now if we want to modify the calculation and change the value of the total when a discount code is entered, we need Conditional Logic. Head over to Advanced > Conditional Logic and add a new condition. Let’s say our coupon code is “coffee” and it’s good for a 25% discount.
Set up the condition like this:
When a user enters “coffee” into the Coupon Code field, the condition will change the value of the Discount Rate field from 1 to .75.
.75 isn’t a typo- to offer a 25% discount, we want to multiply the product total by .75. If you’re doing a flat discount, simply put the value of the discount here. $25 off? Enter 25. Please note, that Ninja Forms can’t generate coupon codes for you. For a step-by-step tutorial on how to set up coupon codes, visit our blog post 3 Easy Steps to Use Coupon Codes in WordPress Forms!
6. Allow users to select a payment method in WordPress form
According to Baymard’s quantitative study of reasons for checkout abandonment collected in 2021, 7% of visitors had abandoned a checkout during the past three months because the site didn’t offer their desired payment option. In fact, 89% of sites offer at least one alternative to credit card payments.
You don’t have to offer every possible payment method to your customers, but if you are limiting yourself to only one, you are leaving money on the table. Having more payment options lead to increased conversions.
Using the Conditional Logic add-on and our payment integrations, you can offer conditional payment options on your WordPress form and allow your visitors to select their preferred payment method.
Simply add a Radio List field to your form that offers the available payment options to choose from. We offer the following payment integrations: Stripe, PayPal Express, Recurly, Elavon, and Authorize.net.
You can also use Select Image Field to let users select their preferred method. This is the field where you can upload images for the payment icons, customize the layout, and display the icons whether horizontally or vertically. You’ll want to make sure the option for Allow multiple selections is turned off.
Once you set up the list field selection, the second step is to Add a Collect Payment action for each payment option and use Conditional Logic on each action so that only the one selected in the Radio List fires.
Giving a choice of payment to your customers results in more loyal and repeat customers who are more likely to return to your store if they know they can pay the way they want. The Conditional Logic add-on lets you give your customers this choice when combined with our payment integrations.
Superpower your forms with conditional logic and work smarter!
Congratulations! You’ve made it all the way here, and that deserves a big shoutout. Now that you’ve learned how to use conditional logic in WordPress, make the most out of it and give the Conditional Logic add-on try. With a 14-day money-back guarantee, you have nothing to lose!
Using the Conditional Logic add-on, your forms will have the ability to create conditional actions in WordPress based on form choices, you can dynamically change your forms based on the selections the user makes while filling out your form. Additionally, you can customize the message after the user submits your form, offer a different lead magnet, redirect users to a thank you page, or offer multiple payment options on your forms.
Unlike our competitors, you can buy the Conditional Logic add-on individually or if you are looking for multiple add-ons, pick one of our membership plans. Conditional Logic is your ticket to smarter forms that will do more of the lifting for you. So don’t wait; free up more of your day for other important things. (naps included!)
Don’t want to miss another article? Sign up for our newsletter below to get notified about the latest blog posts or exclusive deals from Ninja Forms!