pfaffman
(Jay Pfaffman)
2019 年10 月 14 日 23:14
1
我本以为最近见过类似的功能请求,但找不到它。
如果您有一堆用户自定义字段,登录模态框会变得很难看。如果有 10 个可选字段和 2 个必填字段,用户必须滚动很多次才能找到必填字段。这很麻烦。
可以通过 CSS 隐藏这些字段,例如:
.create-account .user-fields .user-field {
display: none;
&:nth-of-type(4){
display: block;
}
}
这有点麻烦,因为您必须通过试错来猜测应使用哪个 nth-of-type。但我可能想提出的一个 是,用于使该模态框正常显示的 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?
master ← custom-field-class
merged 04:22PM - 21 Oct 19 UTC
This makes hiding custom fields with CSS at signup much more reliable.
9 个赞
我刚刚意识到,在这个合并后我从未进行过跟进。现在在注册页面上,所有用户字段都有一个格式为 user-field-name 的类。因此,如果您有一个名为“条款和条件”的字段,它将具有类名 user-field-terms-and-conditions。
您也可以采用快捷方式,在注册时隐藏所有自定义用户字段:
.d-modal.create-account div[class*="user-field-"] {
display: none;
}
7 个赞
pfaffman
(Jay Pfaffman)
2019 年12 月 17 日 10:23
5
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 个赞
这是一个关于解决此问题的已关闭线程,其中包含一个 CSS 解决方案:
I thought that I had seen such a feature request recently, but I can’t find it.
If you have a bunch of user custom fields, the login modal gets ugly. If there are 10 optional fields and 2 required fields, one has to scroll a bunch to find the one(s) that are required. This is a drag.
It’s possible to hide those fields with CSS like:
.create-account .user-fields .user-field {
display: none;
&:nth-of-type(4){
display: block;
}
}
It’s something of a bother, as you have to…
目前,自定义用户字段的选项包括:
注册后是否可编辑?
注册时是否必填?
是否在公开个人资料中显示?
是否在用户卡片中显示?
我认为另一个选项会非常有用:
是否在注册表单中显示?
或者
是否在注册表单中隐藏?
默认情况下,在不进行自定义 CSS 修改的情况下,所有自定义字段(无论是否必填)都将显示在注册表单上。这在一定程度上限制了可实现的自定义字段数量,因为过多的字段会使注册表单显得杂乱无章,并可能让新用户感到畏惧。
11 个赞
pfaffman
(Jay Pfaffman)
2021 年5 月 3 日 16:31
8
有时,拥有一组自定义用户字段会很方便,这样你可以在注册时避免让用户填写不必要的信息。例如,你可能希望用户能够提供他们的地址、邮政编码或发色,但在注册时只要求他们提供姓名和电子邮件地址。
现在,你可以通过使用主题组件隐藏所有自定义字段,然后取消隐藏你需要的字段 来实现这一功能。如果在自定义用户字段设置中有一个复选框,那就更好了。
10 个赞
nathank
(Nathan Kershaw)
2021 年6 月 21 日 23:13
9
这将会很棒。
此外,能够区分注册用户和受邀用户也将非常有帮助,尤其是当某个字段对两者都是必填项,或仅对注册用户为必填项时。
例如,我们要求人们提供“加入原因”,以帮助我们评估其 suitability 并分配群组。对于通过邀请链接加入的人来说,这一步是多余的;但如果该字段为必填项,则无法隐藏,否则会导致他们的注册流程失败。
3 个赞
您好,
我的网站上有一些用户字段,例如社交媒体信息,在注册时其实并不需要填写。
我认为可以增加一个“注册时不显示”的选项,这样该字段在注册时会被隐藏,仅在编辑用户个人资料时可见。
6 个赞
nathank
(Nathan Kershaw)
2022 年12 月 18 日 20:12
11
您已经可以通过 CSS 实现此目的:
但是的,将其作为明确的选项会非常好!这已经被要求过几次了。
我已将所有关于此的 Feature 主题合并到此主题中。
4 个赞
Richie
(Richie Rich)
2023 年2 月 27 日 16:28
19
注册模态框是否有任何更改可能导致此 CSS 不再生效?
我无法使用 @pfaffman 在第一篇帖子中的代码隐藏注册页面上的任何自定义字段,也无法使用 @awesomerobot 的代码隐藏所有自定义字段:
我一直将 CSS 应用于 Themes > Common > CSS。
2 个赞
看起来 Discourse 的其他地方添加了一些更具体的 CSS,这覆盖了 display:none…
.d-modal.create-account .user-field {
display: flex;
}
我将快速查看 ,看看我们是否需要如此具体,但与此同时,这个 更新应该可以工作:
.d-modal.create-account div[class*="user-field-"] {
display: none;
}
2 个赞
Richie
(Richie Rich)
2023 年2 月 28 日 15:36
21
Kris:
I’ll take a quick look at and see if we need to be this specific, but in the meantime this update should work:
.d-modal.create-account div[class*=\"user-field-\"] {
display: none;
}
Confirmed, this worked perfectly to hide them all!
Thank you so much Kris @awesomerobot
1 个赞
Moin
2025 年10 月 4 日 12:32
23
添加了一个隐藏用户字段的设置,使其不显示在注册表单上:
hugh:
注册表单中隐藏自定义字段的选项
3 个赞
mcwumbly
(Dave McClure)
关闭
2025 年10 月 7 日 12:32
24
此主题在最后回复后 3 天自动关闭。不再允许新回复。