Hide some user custom fields from new account page

AI-generated summary

The discussion revolves around hiding specific user custom fields from the new account page in Discourse. pfaffman asks about safely targeting fields using ember-xxx tags or hiding fields via settings. sam suggests unchecking fields in admin settings, but pfaffman notes this doesn’t work as expected. david clarifies that all fields are shown in the signup modal and advises against using ember-xxx tags, recommending :nth-of-type selectors instead. pfaffman confirms this approach works, using CSS to hide all fields except the 10th.

I have a bunch of user custom fields from an import. I would like only one of them to be included on the login page. When I look at the CSS, the different fields are tagged with only an ember-xxx tag. Is it safe to use those tags to target individual fields or are they likely to change if . . . something … changes?

Edit: Or if there were a way to make a user custom field as “hidden from user” that would be another solution to the problem.

Pretty sure that if you define a user field in admin and tick nothing, it will not show up to end users. We implemented that a few months ago.

That’s what I thought, but all the fields are un-checked and they all show up on the new user page.

To you or the end user, pretty sure @david tested this.

We serialize all user fields for staff members, and for the user themselves

I think @pfaffman is talking about the signup modal, where we always show all fields.

Short answer: no :wink:

The slightly safer method, if this is for a specific site, would be to use the nth-of-type selector

.user-fields div{
  display: none;

  &:nth-of-type(2){
    display: block;
  }
}

I think a PR to add data-field-name=blah to the div elements would be welcome.

Thanks, @david! That wasn’t quite right, but it was enough to get me there. Here’s what I did:

.create-account .user-fields .user-field {
    display: none;
    
    &:nth-of-type(10){
        display: block;
    }
}