Apps Ballance Cash_2 Chat Checkout Click Code Cog_Wheels Compose_email Conference Contacts Earth Edit_File_1_ Email Email_2 File Folder_2 Gift Group Group_2 Help ID ID_2 Key Keys Laptop_Store Like_1_ Link Lock Log_Out Map Marketing Mobile_UI Navigation POS Partnership Profile Safe_2 Search_User Secure_Files Settings Share Shield Shield_2 Shopping_Cart Support_Male Trash Type_pin User_female User_male logo copy

Creating Fields With Conditional Logic

Iain Poulson avatar
Iain Poulson Last updated on April 26, 2021

Using conditional logic in WordPress allows users to create dynamic form fields that collect only the most relevant information when needed.

If you want to provide your users with all the necessary fields but don’t want to clutter your form fields, then a conditional field is the best option for you.

Conditional logic allows your WordPress forms to change or show additional fields based on the user’s selections, show custom text fields, and many more.

How To Enable Conditional Fields

You can use conditional logic to most of your forms field depending on the information you need from users. 

Let’s take for example this simple Registration Form.

You want your users to also add their phone numbers instead of just their names and email addresses.

  1. To enable conditional fields on your WordPress site go to your Dashboard, navigate to Users > Custom Fields > Customize fields.

  1. You can either edit existing fields or add new custom fields.

  1. You need to have separate fields for your existing field and your conditional fields. Your conditional field is the one that will appear if the conditions are met on your existing field.
  1. In this example, we will use the ‘Add Phone Number’ field as the existing field, and the ‘Phone Conditional Logic’ field as the conditional field.
  2. To enable the conditional logic choose your desired conditional field and then click ‘Edit field’.

  1. Select ‘Conditional Logic’ then turn on the ‘Enable conditional logic’. Select what conditions you want to meet for your conditional field to appear or function.
  1. In this example, you want the ‘Phone Number’ (conditional) field to appear if the ‘Add Phone Number’ (existing single checkbox) field has value. Then click ‘Save Changes’.

  1. After you enable the conditional field, the next step is to add both the existing field and the conditional field to your registration form.
  1. To do that go to your Dashboard, navigate to Users > Registration Forms > Customize Form.

  1. On your Registration Form field, drag and drop both the ‘Existing Field’ and the ‘Conditional Field’ from the list of the Available Fields to your Form Fields.

  1. Your changes will be automatically saved and your conditional field is now ready.

Testing the Conditional Logic

To test your conditional logic field log out of your account, open your website, and go to your Registration form. The Existing field should appear, which is the ‘Add Phone Number’ field in our example.

You will notice that the conditional field, which is the ‘Phone Number’ does not appear on the Registration form because the condition is still not met.

To meet the conditions you set, select the ‘Add Phone Number’ checkbox and the conditional field will appear below the existing field.

WP User Manager logo

Get Started with the Best WordPress Membership Plugin Today

Connect, Manage and Build your Membership Site

Need more help?

If you still didn't find an answer you can always contact us

Submit a ticket