Discourse Authentication Validations

:discourse2: Summary Discourse Authentication Validations enables the ability to add custom validations to a User Field to toggle the display of User Fields on the Signup Modal.
:hammer_and_wrench: Repository Link https://github.com/discourse/discourse-authentication-validations
:open_book: Install Guide How to install plugins in Discourse

About :information_source:

Discourse Authentication Validations adds the ability to add custom validations to a User Field to toggle the display of User Fields on the Signup Modal. This allows you to “chain” User Fields together, so that a User Field is only displayed if a previous User Field has a specific value.

Demo :clapper:

Basic Setup :building_construction:

1. Enable Plugin

The Discourse Authentication Validations plugin can be enabled either by the toggle or from its settings, both accessible from your admin/plugins page.

2. Add a custom validation to a User Field

After the Discourse Authentication Validations plugin has been enabled you will see a Include a Custom Validations checkbox at the bottom of your User Field form.

When checked it will display an additional two fields:

  1. Show Values
  2. Target User Fields

3. Add a Show Value

When a User Field has a show values value included it will watch the value of the attached input until the input value matches ANY of the show values. It will then toggle the visibility of any included Target User Fields, making them visible.

4. Add a Target User Field

In the Target User Fields dropdown you will see a list of all available User Fields. Any User Field you select will have their visibility toggled by corresponding values in show values.

Advanced Chaining :hammer_and_wrench:

You can chain User Fields together by adding custom validations to multiple User Fields.

For example, let’s say we have three User Fields with the given values:

Name Has Custom Validation Show Values Target User Fields
Input One true show-field-two Input Two
Input Two true show-field-three Input Three
Input Three false

Input Two and Three will be hidden by default as they are “children” of Input One. When the show value of show-field-two is added to Input One, Input Two will be displayed, but Input Three will still remain hidden. It will remain hidden until Input Two has the value of show-field-three.

With the correct combination of Show Values and Target Classes you can infinitely nest User Fields beneath each other.

10 Likes