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 existing or pre-defined field.

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 the field modal or clicking the edit icon to edit an existing field. Near the bottom of the field modal, you will see text that says: “Add conditional fields support”. Clicking on this text will open the conditional logic options.

Adding a condition #

Thick the "+" icon to add one more condition. Each condition is a line with inputs: Action, Field selection, Operator, Value.

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 the  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.

Warning: Conditional logic is strictly hierarchical. Cross dependencies are not allowed. This means that you can make field B depend on field A or field A depend on field B. But if you make field B depend on field A and field A depend on field B, it will cause an error.

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 – this field will show/hide if the selected field is empty (e.g. has no user input)
  • Not Empty – this field will show/hide if the selected field is not empty (e.g. the field has user input)
  • Equals to – this field will show/hide if the selected field is equal 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 the country list then the field will show/hide)
  • Not equals – this field will show/hide if the selected field is not equal 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 the country list then the field will show/hide)
  • Greater than – 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 – 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 – this operator requires no value input and should be left with the default 0
  • Not Empty – this operator requires no value input and should be left with the default 0
  • Equals to – the value may be either text or number. If entering text make sure the text matches exactly with what the user selects (e.g if the user selects Male from the gender field make sure you set the value as Male and not male).
  • Not equals – the value may be 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 the gender field make sure you set the value as Male and not male).
  • Greater than – this operator requires that the value be a number, not text.
  • Less than – this operator requires that the value be a number, not 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 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 switchers - 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.

Exceptions #

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.