Conditional Logic

Overview

Ultimate Member provides conditional logic within the form builder which allows you to configure your registration, login or profile form to show or hide fields based on user selections. Conditional logic can be applied to a field when creating a new field or editing an exisiting or pre-defined field.

Warning: All conditional fields must be optional, you can't make them required.

Adding conditional logic to a field

To add conditional logic to a field you need to open up an individual field’s options by adding a new field from field modal or clicking the edit icon to edit an exisiting field. Near the bottom of the field modal you will see text that says: “Add conditional fields support”. Clicking on this text to will open the conditional logic options.

Action

The basic idea with conditional logic is that you show or hide a field based on the user’s selection of another field. If you select show, the field will only appear on the form once the conditions are met. If you select hide, the field will disappear from the field once the conditions are met.

Field selection

The second input required for conditional logic is to select the field which will trigger the conditional logic to show/hide. Click the dropdown and select the name of the field from the list. Only fields that have been added to the form are shown in this dropdown.

Operator

The third input required for conditional logic is to select the operator that will trigger the conditional logic. There are several operators to choose from:

  • Empty – If empty is selected this means that this field will show/hide if the selected field is empty (e.g has no user input)
  • Not Empty – If not empty is selected this means that this field will show/hide if the selected field is not empty (e.g the field has user input)
  • Equals to – If equals to is selected this means that this field will show/hide if the selected field is equals to the text or number you set in the value input (e.g if you set the value input to be London and the user selects London from country list then the field will show/hide)
  • Not equals – If emtpy is selected this means that this field will show/hide if the selected field is not equals to the text or number you set in the value input (e.g if you set the value input to be London and the user selects New York from country list then the field will show/hide)
  • Greater than – If greater than is selected this means that this field will show/hide if the selected field is greater than the number you set in the value input (e.g has no user input)
  • Less than – If less than is selected this means that this field will show/hide if the selected field is greater than the number you set in the value input (e.g has no user input)
  • contains – this field will show/hide if the selected field contains the text or number you set in the value input. This operator should be used if the selected field type is "Checkbox", "Dropdown", "Multi-Select" or "Radio" - these field types save data as an array.

Value

The final input required for conditional logic is to set the value. This involves entering the text or number that will trigger the field to show/hide. Below is what you can enter into the value input for each operator type:

  • Empty – The empty operator requires no value input and should be left with the default 0
  • Not Empty – The not empty operator also requires no value input and should be left with the default 0
  • Equals to – The equals to operator can contain either text or number. If entering text make sure the text matches exactly with the what the user selects (e.g if the user selects Male from gender field make sure you set the value as Male and not male).
  • Not equals – The not equals operator can contain either text or number. If entering text make sure the text matches exactly with the what the user selects (e.g if the user selects Male from gender field make sure you set the value as Male and not male).
  • Greater than – The greater than operator should only be used for numbers and not for text.
  • Less than – The less than operator should only be used for numbers and not for text.
  • contains – The value must be the same as one of the choices in the field-switcher. For example: your field-switcher contains choices "first item", "second item", "third item". You should use one of these values. Values "first", "item" or "first item second item" would not work.

Adding multiple conditions

It is possible to add more than one condition to each field. You are able to add up to five conditions per each field. This means you have more flexibility over what conditions will make a field show/hide on the form.

Conditional fields don't use "AND" or "OR" logic. Conditional logic is based on form actions. The related field will be changed (shown or hidden) when the value of the field-switcher is changed. That's why we recommend using the combination "single switcher - multiple related fields" and don't recommend using combination "multiple switcher - single related field".

You should add several rules to the related field's conditional logic if you want to show related fields for several choices of the field-switcher.

Exeptions

Roles

You may use conditional logic with the field types "Roles (Dropdown)" and "Roles (Radio)". In this case you should use these settings to manage conditional fields:

  • Action - "show"
  • Field - select the field-switcher;
  • Operator - "contains";
  • Value - the slug of the target user role in the field-switcher.

User Tags

You may use conditional logic with the field type "User Tags". In this case you should use these settings to manage conditional fields:

  • Action - "show"
  • Field - select the field-switcher;
  • Operator - "contains";
  • Value - the ID number of the target tag in the field-switcher.