회원가입 페이지에서 사용자 정의 필드를 숨기는 사이트 설정

최근에 이런 기능 요청을 본 것 같은데, 찾을 수가 없네요.

사용자 정의 필드가 많으면 로그인 모달이 지저분해집니다. 선택 필드가 10개이고 필수 필드가 2개라면, 필수 필드를 찾으려면 꽤 많이 스크롤해야 합니다. 정말 귀찮은 일이죠.

다음과 같은 CSS로 해당 필드를 숨길 수는 있습니다:

.create-account .user-fields .user-field {
    display: none;

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

}

어떤 nth-of-type을 사용해야 하는지 시행착오로 추측해야 해서 다소 번거롭지만, 제가 제안하는 것은 :bug: 이 CSS가 모달을 올바르게 보이게 하던 스타일이 가끔씩 변경된다는 점입니다. 최근 beta6에서 변경된 것으로 보입니다. 이는 제 클라이언트에게 슬픈 일이었습니다. 필수 필드가 보이지 않아 사람들이 가입할 수 없었거든요. 누군가 불만을 메일로 보내서야 알게 되었습니다.

문제 해결!

해당 필드에 CSS가 추가되어 더 이상 이런 문제가 발생하지 않습니다!

10개의 좋아요

I don’t think it would be hard to add a class or data attribute that includes the custom field’s name, which would make it much less fragile to target with CSS. I can probably get to that within the next couple of days.

7개의 좋아요

Took a quick look and it’s nearly identical to another PR I opened recently to add a class to tag groups. So here’s a PR for this… we might want to add a helper to sanitize class names before merging these?

https://github.com/discourse/discourse/pull/8193

9개의 좋아요

I just realized that I never followed up after this was merged. Now on the signup page all user fields have a class in the form of user-field-name. So if you had a field with the name “terms and conditions” it would have the class user-field-terms-and-conditions.

You can also take a shortcut and hide all custom user fields at signup with

.d-modal.create-account div[class*="user-field-"] {
    display: none;
}
7개의 좋아요

Thanks! I managed to get this done a week or two ago. You might edit that list to also include the css to un-hide a field or two after hiding the rest.

2개의 좋아요

Here is a closed thread about solving this, which includes a css solution:

Right now for custom user fields, the options are:

Editable after signup?
Required at signup?
Show on public profile?
Show on user card?

I think another option would be quite useful:

Show on signup form?
or
Hide on signup form?

By default, without custom CSS modification, all custom fields (optional or not) will be displayed on the registration form. This somewhat limits the amount of custom fields that can be implemented as having too many will make the registration form overloaded and potentially intimidating to new users.

11개의 좋아요

Sometimes it is nice to have a bunch of custom user fields to ask for information that you don’t want to bother people with on signup. For example, you might want to have the ability for someone to provide their address, zip code, or hair color, but on signup ask them only for their name and email address.

This is possible now by using a theme component to hide all custom fields and then un-hide the ones you want. It would be nice if there were a checkbox in the custom user field settings.

10개의 좋아요

This would be great.

It would also be helpful to be able to differentiate sign-ups and invitees, especially if a field is mandatory for both or just for signups.

For example, we ask people to provide their “Reason for Joining” to help us decide their suitability and group. This is redundant when people arrive via an invite link, but it can’t be hidden if mandatory or it breaks the signup for them.

3개의 좋아요

Hello,

There are some user fields on my site which really dont need to be present at signup, such as socials.

I think we could benefit from a “Do not display at signup” option option, making it hide during signup and only be visible when editing your user profile.

6개의 좋아요

이미 CSS를 통해 이 기능을 구현할 수 있습니다:

네, 이것이 명시적인 옵션으로 제공되면 정말 좋겠습니다! 몇 번이나 요청이 들어왔습니다.

이 주제와 관련된 모든 Contribute > Feature 토픽을 이 토픽에 통합했습니다.

4개의 좋아요

It also got a bit of traction in this topic too:

11개의 좋아요

Has something changed on the signup modal that might cause this CSS to not work anymore?

I can’t hide any custom fields on the signup page by using either the code in the first post by @pfaffman - nor can I hide all of the custom fields by using the code from @awesomerobot :

I’ve been applying the CSS to Themes > Common > CSS.

2개의 좋아요

It looks like some more specific CSS was added elsewhere in Discourse, and that’s overriding display:none

.d-modal.create-account .user-field {
  display: flex;
}

I’ll take a quick look at :point_up: and see if we need to be this specific, but in the meantime this :point_down: update should work:

.d-modal.create-account div[class*="user-field-"] {
  display: none;
}
2개의 좋아요

Confirmed, this worked perfectly to hide them all!

Thank you so much Kris @awesomerobot :smiley:

1개의 좋아요

가입 양식에서 사용자 필드를 숨기는 설정이 추가되었습니다:

3개의 좋아요

이 주제는 마지막 답변 후 3일이 지나면 자동으로 닫힙니다. 더 이상 새 답변을 남길 수 없습니다.