Conditional user fields

Use case

We're working on improving the onboarding experience of our community. Naturally, we'd like to use information we know about the user to do/show certain things based on the information they give us. Today, our users start their account creation through our OIDC integration by creating an account with our company. They provide email, name, and username to OIDC before it kicks them back over to Discourse.

The problem

We'd like to now give them some additional user fields to fill out—which is great, because Discourse offers this! Unfortunately we can't show fields based on the responses of previous fields. For example, we'd like to ask, "What role best describes you?" with the options, developer, administrator, and analyst.

If they choose developer, I of course want to ask them what their preferred programming languages are. I will also later add them to the developer user group.
If they choose analyst, I want to ask them a different series of questions, and add them to a different user group.

Proposed solution

Many form options across the web today offer conditional form fields (e.g. where did you hear about us? if 'other' is selected, an additional field shows up to say why.). It would be great if you started down a similar (yet more robust) path as you have with new topic form templates, though with the added requirement of the ability to depend on another field ID, and specifically that field's input. As an example, it might look something like this: - type: dropdown id: user-type choices: - "Developer" - "Application Administrator" - "Analyst" attributes: none_label: "Choose your role..." label: "Which option best describes your job" validations: required: true - type: dropdown id: developer-type-programming-language depends: user-type choices: - "Developer" choices: - "Developer" - "Application Administrator" - "Analyst" attributes: none_label: "Preferred programming language..." label: "What is the primary programming language used in your role?" validations: required: true

In this example, all users would be asked the first question. If the user selects Developer from the drop-down list, then a second question would appear on the form asking what their preferred programming language is.

This conditional field improvement could be used in both the user onboarding process as well as the original intended place of new topics as well.

Discuss this on our forum.