Hide some user custom fields from new account page

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.

1 Like

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.

1 Like

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

https://github.com/discourse/discourse/blob/master/lib/guardian/user_guardian.rb#L105-L109

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.

4 Likes

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;
    }
}
4 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.