Documentation, Reference Materials and Tutorials for WPForms
Would you like to set some form fields to hide or display when specific conditions are met? With smart conditional logic in WPForms, you can customize forms by setting fields to show or hide fields depending on a user’s selections. AND/OR logic will allow you to take this a step further and create multiple conditions.
In this tutorial, we’ll show you how to use AND/OR conditional logic in your forms.
Before we get started, you’ll need to create a form or edit an existing form.
Once the form builder is open, you can click on any field in the preview area to open its Field Options panel. From here, you’ll need to open the Conditionals section and then check the box labeled Enable conditional logic.
After checking this box, you’ll be able to add your conditions. We’ll share all of the details on how to set up conditions for both AND and OR logic in the sections below.
How to Use OR Logic
The purpose of OR logic is to provide a flexible set of two or more conditions. If any one of these conditions are met, the field will show/hide.
As an example, we’ll ask any users who provide a 4 or 5 star rating if they’d be willing to write a review.
To get started, we’ll first add a Rating field. Then we’ll add a Checkboxes field where our user can indicate if they’d be willing to share a review.
After enabling conditional logic for our Checkboxes field, we can set up our conditions. For the first condition, we’ll select Show this field if Please rate your experience field is set to 4.
To add a second condition with OR logic, we’ll click the Add new group button.
After clicking this button, you’ll see an or label appear followed by a second set of condition options. For our example, we’ll add logic to display the field if the Please rate your experience field is set to 5.
When the form is viewed, the user will now see this field if they provide a 4 or 5 star rating.
How to Use AND Logic
The purpose of AND logic is to indicate that you want two or more conditions to all be met at the same time. To demonstrate this, we’ll continue our example from above.
For our example, we’d like to ask slightly different questions for reviews depending on whether the user selects 4 or 5 stars. Below, we’ll set up a Paragraph Text field to only display if the user chooses 5 stars.
To do this, we’ll first add a Paragraph Text field to our form and add some details to be sure our user knows what details we’d like included.
Then, we’ll enable conditional logic and set up our first rule: Show this field if the Please rate your experience field is set to 5.
To add a second rule with AND logic, we’ll need to click the AND button.
Our second rule will read: Show this field if the Would you be willing to write a review? field is set to Yes, and I’d like to write it here.
With this AND logic in place, this Paragraph Text field will only display if the user chooses a 5 star rating and also indicates that they’d be willing to write a review within our form.
To complete the form, we would create a slightly different Paragraph Text field to collect 4 star reviews. Then, we would display this conditionally by repeating the setup described above.
That’s it! You can now create custom forms with AND/OR conditional logic.
Next, would you like to add conditional logic to your notification emails? Be sure to check out our tutorial on conditional notifications to find out how to send out different notifications based on a user’s form selections.