Using the conditional logic with Ninja Forms for WordPress

Are you looking out for conditional programming in Ninja Forms in WordPress then you have approached the right plugin? Ninja forms are one of the biggest pieces of code which provides you with an easy way to develop forms on WordPress. Its significant drag and drop features anyone can install the form and get it going for its website.

WordPress is one of the leading platforms that provide you with a fantastic opportunity to create attractive websites for your business. It’s not only that, but it also gives you thousands of plugins that make your life easier by providing you with different functionalities with drag and drop features.

Ninja Forms is free of cost form builder plugin available for WordPress that allows you to create any type of form for data collection. Whether it is simple to contact forms or event registrations, file uploads, payment or any complicated scenario, it is the right option for everyone when it comes to creating conditions on your WordPress website.

Ninja Forms unique features have led to its immense popularity in the market, and one of the proofs of this is that it has been downloaded over 11,000,000 times by clients. Moreover, millions of WordPress websites are using it for developing rare forms. So, let’s move on to the guideline through which you will be able to create conditional logic in Ninja forms on your website.

Here are some basic features of Ninja form because of which they have become so popular among website designers. So let’s have a look

  • A user-friendly plugin that comes with form builder
  • Highly beginner-friendly
  • Create a beautiful and attractive website even if you are not a designer
  • Can be developed even if you are not a developer. Easy drag and drop features
  • Payment form options to integrate payment gateway on your website
  • Numerous form options such as signup forms and lead generation forms
  • Thousands of pre-built templates that will allow you to get started right away without any help of a developer
  • Responsive websites are websites which provide you with the option to use the same design on different screen sizes without any customization. Ninja Forms also offers you responsive website plugins that fit in with different screen sizes.  
  • It provides different integration as compared to any other WordPress form builder plugin available on WordPress.
  • It provides an add-on feature for the websites providing numerous opportunities for you to grow your business. Here are some of the addons that come along with Ninja forms providing a fantastic opportunity for you to increase your website.
    • Layout & Styles
    • Conditional Logic
    • Multi-Part Forms
    • File Uploads
    • PDF Form Submissions
    • Excel Export
    • Save Progress
    • User Management
    • Front End Posting
    • User Analytics
    • Webhooks

After getting to know about these unique features, you surely don’t want to be left behind so download Ninja Forms and get going.

What is Conditional Logic?

Before we move on to step by step guideline, our users need to be on the same page. Therefore, we will be giving a light introduction to conditional logic. Conditional logic is functionality in programming that allows users to create and update dynamic elements. All the decisions are dependent upon the given input.

Let’s show you an example that will show you how conditional logics work in programming.

  • Assume you have a form that takes information from the candidates about their education.
  • The specialization dropdown will only be visible to candidates who will opt for PhD while others will only add their respective degrees.
  • Here comes the conditional logic where the computer will decide whether to show a dropdown or a simple input field based on the user input.

Step by step guide to set up conditional logic in Ninja Forms

Here in this step by step guide, we will be following an example where we will be sending an email to the user based on a particular logic. It is effortless to set up conditional logic for sending emails to different users. So let’s get to the task!

To do so, we will be using our Conditional Logic extension. It is an extension that will add the ability to set up conditions across the form that you will develop. Adding criteria to send conditional email is one of the numerous things that you can do in conditional statements.

It is noteworthy to note that all the conditional statement in Ninja form 3.0 have moved to a centralizes control centre. The Advanced tab of the form builder is the place where you can find all these controls. The email actions, however, contain the logic operations conveniently cooked into the action window. Wait a minute, let it sink, and don’t get disappointed because we are moving ahead to show you how you can set up statements to send emails based on different conditions.

We have got a Quote request form made for you to allow you to enjoy the work related to the conditional logic.

Having a look at the form above we get to know that we have to send an email to the concerned department upon the user input of “What services may we assist you with?”.  As per the user input, we will select the relevant email address of that particular department and inform them that someone is looking for a quote.

Moreover, we also have to implement the logic that if the question is left unanswered, then it will not send email to any department. So now we have two conditions to check first the department and then selection of the relevant email.

Step 1

Here comes the first step, where you have to create email action for each department. Follow the steps below to make the emails, and then we can move ahead towards our logic building.

  • Go to the form builder
  • Hit the Emails in the Action tab.
  • Add an email action for each department. The below screenshot shows how you can open the action menu window.
  • Ensure that you give precise and understandable names to each action so that it is easy for you to locate the stories afterwards. Or if anyone after you comes over to change something can understand the steps easily.

Step 2

Now comes the real action where you need to add the conditional logic to ensure that the form acts according to the desired to be a behaviour to add the condition hit the first email action so that we could add a conditional statement.

Following is the screenshot that will show a slide action window where you will write your conditional logic to let the form act accordingly.