# Date Type On Custom User Fields

**URL:** https://meta.discourse.org/t/date-type-on-custom-user-fields/47357
**Category:** Feature
**Tags:** completed
**Created:** [2016年七月15日 14:06 UTC](https://meta.discourse.org/t/date-type-on-custom-user-fields/47357 "2016-07-15T14:06:38Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![redprogrammer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/redprogrammer/32/121004_2.png) [@redprogrammer](https://meta.discourse.org/u/redprogrammer)
#### Post date: [2016年七月15日 14:06 UTC](https://meta.discourse.org/t/date-type-on-custom-user-fields/47357/1 "2016-07-15T14:06:38Z")

</div>

Hi,

i wanto to add date picker named with birthday on signup ,  
but in customize-\>user fields part 3 input tpyes

how can i add datepicker to signup part?

Best Regards

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [2018年三月8日 09:38 UTC](https://meta.discourse.org/t/date-type-on-custom-user-fields/47357/2 "2018-03-08T09:38:04Z")

</div>

Bump …

Any reason why you can’t choose a Date Type for User Custom Fields? This would be useful for one of my forums, and not just for birthdays …

I’m aware of this plug-in but it seems it only handles birthday entry? what about other anniversaries or fixed dates?

> [@Discourse Cakeday](https://meta.discourse.org/t/cakeday-celebrating-birthdays-and-anniversaries/38447?source_topic_id=59615):
>
> discourse2Summary Discourse Cakeday decorates user avatars with a celebratory emoji on the anniversary of their joining day, and (optionally) on their birthday too. cake birthdayopen_bookInstall Guide This plugin is bundled with Discourse core. There is no need to install the plugin separately. Enabling Cakeday The Cakeday plugin is default enabled but can be disabled/enabled from its settings, accessed from your admin/plugins page: [Cakeday settings] Features …

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [2018年四月20日 05:13 UTC](https://meta.discourse.org/t/date-type-on-custom-user-fields/47357/3 "2018-04-20T05:13:21Z")

</div>

Guys, I was thinking of forking cake day for my own purposes but I’d much rather dates were allowed for custom user fields, any reason why not? Wouldn’t thIs be a relatively small change to core?

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [2018年十二月19日 21:29 UTC](https://meta.discourse.org/t/date-type-on-custom-user-fields/47357/4 "2018-12-19T21:29:58Z")

</div>

Another bump for this one given we appear to have just iterated to a new release phase 😉

---

<div class="post-metadata">

### Author: ![nobodyfrm](https://avatars.discourse-cdn.com/v4/letter/n/e0b2c6/32.png) [@nobodyfrm](https://meta.discourse.org/u/nobodyfrm)
#### Post date: [2019年十一月15日 08:33 UTC](https://meta.discourse.org/t/date-type-on-custom-user-fields/47357/5 "2019-11-15T08:33:51Z")

</div>

我想使用出生日期进行年龄验证。

---

<div class="post-metadata">

### Author: ![snehbaxi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/snehbaxi/32/218026_2.png) [@snehbaxi](https://meta.discourse.org/u/snehbaxi)
#### Post date: [2020年六月2日 10:33 UTC](https://meta.discourse.org/t/date-type-on-custom-user-fields/47357/6 "2020-06-02T10:33:35Z")

</div>

顶一下，有三个问题：

- 为什么不能为客户用户字段添加日期类型？请添加此功能。  
我的用例也是在注册时验证社区成员的年龄。

- 是否有办法将“蛋糕日”自定义为包含出生年份？

- 希望设置某些用户资料字段为注册后必须填写的必填项。

---

<div class="post-metadata">

### Author: ![James\_Lodge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/james_lodge/32/192997_2.png) [@James\_Lodge](https://meta.discourse.org/u/James_Lodge)
#### Post date: [2020年十月28日 09:27 UTC](https://meta.discourse.org/t/date-type-on-custom-user-fields/47357/7 "2020-10-28T09:27:33Z")

</div>

这有进展吗？我想通过出生日期来验证年龄。

---

<div class="post-metadata">

### Author: ![nicolailang](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nicolailang/32/159049_2.png) [@nicolailang](https://meta.discourse.org/u/nicolailang)
#### Post date: [2021年二月27日 12:51 UTC](https://meta.discourse.org/t/date-type-on-custom-user-fields/47357/8 "2021-02-27T12:51:57Z")

</div>

是的，我还需要年龄验证——这也是我们尚未完成迁移的主要原因。

核心开发者的观点似乎是“你们无法验证用户是否诚实”。我完全明白这一论点，但请允许我作为负责任的站点所有者自行处理此事。

因此，目前我不得不让用户通过手动操作，向管理员发送私信声明自己已满 15 岁或 18 岁，以获得访问受限分类的权限。

等我抽出更多时间后，我需要着手开发一个插件来解决这个问题。

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2021年二月28日 02:02 UTC](https://meta.discourse.org/t/date-type-on-custom-user-fields/47357/9 "2021-02-28T02:02:26Z")

</div>

此处注册时有一个基本的验证形式，底部显示：

> 注册即表示您同意隐私政策和服务条款。

 ![image](https://global.discourse-cdn.com/meta/original/3X/7/5/75ef73e6f9d37915783b0310c63320782a6fe629.png)

您可以轻松编辑该文本（正如您可以在 Discourse 中编辑\_任何\_文本一样），将其改为类似：

> 注册即表示您确认自己已年满 13 岁，并同意隐私政策和服务条款。

---

<div class="post-metadata">

### Author: ![nicolailang](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nicolailang/32/159049_2.png) [@nicolailang](https://meta.discourse.org/u/nicolailang)
#### Post date: [2021年二月28日 12:01 UTC](https://meta.discourse.org/t/date-type-on-custom-user-fields/47357/10 "2021-02-28T12:01:05Z")

</div>

谢谢 Jeff，我意识到我之前的回复不够准确。

我们需要能够根据年龄区分用户，并将他们分组。原因在于：我们有一个仅限 15 岁以上用户（寻求联系）的类别，几个仅限 18 岁以上用户（成人/性主题）的类别，甚至还有一个仅限 20 岁以下用户的类别（为未成年人提供避开掠食者和怪人的安全空间）。

目前，我正在将社区从一个基于 Joomla 的网站（使用 Kunena、K2、Cobalt 和 JomSocial 组件）迁移到一个更简单的、仅基于 Discourse 的新网站（完成后，我会提交一个包含导入脚本的 PR，并留出时间进行文档说明）。

目前我们通过让用户加入特定群组来解决这个问题，并运行一个每 5 分钟执行一次的 SQL 脚本，用于移除违规加入群组的用户并通知管理员。

在我正在设计的 Discourse 新架构中，我在用户个人资料页面添加了一个 JavaScript 日期选择器。目前，现有用户会在导入过程中被添加到相应群组。在新用户管理方面，在我有时间编写一个 Sidekiq 任务来自动化处理之前，暂时需要手动操作。由于我们每周新增用户通常不超过 5 人，因此目前的管理负担是可控的。

我确实无法确认用户是否如实填写了年龄，但我们的社区一直以此方式运营了 20 年，包括与丹麦执法部门打交道，他们曾明确表示我们做得对。

我们通常鼓励用户诚实，而不是限制访问，这样我们才能以适当的方式与年轻用户沟通，并准备好保护他们，而不是将他们拒之门外，或迫使他们为了获得访问权限而谎报年龄。

在丹麦，同意年龄为 15 岁，法定成年年龄为 18 岁。根据法律，实际上对访问色情内容没有年龄限制。作为社区，我们将硬核内容和性相关图片限制在 18 岁以上用户，以避免每隔几年就会引发的激烈争论🔥。

在迁移过程中，我正在重写规则集，并且肯定会加入一条明确的声明：如果您未满 13 岁，则需要获得父母的许可才能创建个人资料（相信我，我们的用户中没有人会真的去征求父母的许可😊）。

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2021年二月28日 19:59 UTC](https://meta.discourse.org/t/date-type-on-custom-user-fields/47357/11 "2021-02-28T19:59:09Z")

</div>

> [@nicolailang](#):
>
> 原因是我们有一个仅限 15 岁以上（寻求联系）的版块，几个仅限 18 岁以上（成人/色情主题）的版块，甚至还有一个仅限 20 岁以下的版块。

我明白了——你需要使用版块权限来隔离这些群体。

至于年龄证明，你可能需要法律认可的证明，也就是需要他们官方政府身份证的照片，对吗？

---

<div class="post-metadata">

### Author: ![nicolailang](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nicolailang/32/159049_2.png) [@nicolailang](https://meta.discourse.org/u/nicolailang)
#### Post date: [2021年二月28日 21:29 UTC](https://meta.discourse.org/t/date-type-on-custom-user-fields/47357/12 "2021-02-28T21:29:29Z")

</div>

> 关于年龄证明，您可能需要法律认可的证明，即需要提供其官方政府身份证的照片，对吗？

如果我们是一家企业并因此产生收入，这确实是一个可行的途径（我们拥有官方数字签名）。否则，在 GDPR 的框架下，任何其他方式都会是一场噩梦。

无论如何，本社区是非商业性质的，法律上我们并无义务进行任何验证。总体而言，欧洲，尤其是丹麦，在成人内容方面比美国更为宽松。标准免责声明：我绝非法律专家，强烈建议任何读者寻求专业法律咨询 🙂

---

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [2021年五月9日 02:25 UTC](https://meta.discourse.org/t/date-type-on-custom-user-fields/47357/13 "2021-05-09T02:25:23Z")

</div>

> [@snehbaxi](#):
>
> 是否有一种方法可以自定义“蛋糕日”，使其包含出生年份？

这对人口统计分析将非常有用。在我们其中一个网站上，我们为此目的按十年收集“年龄段”，这有点滑稽，因为每年其准确性会下降 10%！我们本应该收集出生年份（或出生年代），但毕竟事后诸葛亮总是 20/20 的准度。

如果将出生日期（DOB）内置到像 Cakeday 这样的官方插件中，并且该字段能够通过“投票细分”（Polls Breakdown）访问，那将非常理想。当然，这应作为一个可配置的选项，以满足那些更重视隐私的论坛的需求。

---

<div class="post-metadata">

### Author: ![DaVania](https://avatars.discourse-cdn.com/v4/letter/d/a9adbd/32.png) [@DaVania](https://meta.discourse.org/u/DaVania)
#### Post date: [2022年四月10日 22:02 UTC](https://meta.discourse.org/t/date-type-on-custom-user-fields/47357/14 "2022-04-10T22:02:48Z")

</div>

为了挑战自己（学习一些 Ruby），我尝试为出色的 cakeday 插件添加一些代码，该插件在遵守现有编码约定和我自身能力的同时，考虑了 **隐私和安全** 。

代码可以在 [https://github.com/DaVania/discourse-cakeday/commits/discourse-cakeday\_with-age](https://github.com/DaVania/discourse-cakeday/commits/discourse-cakeday_with-age) 查看。

我希望 🙏 它能有所帮助，而且由于这是我第一次作为贡献者使用 Github，我怀疑并非一切都尽善尽美，尽管我为此付出了许多夜晚和数月的心血。（尽善尽美）

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2022年十一月17日 16:20 UTC](https://meta.discourse.org/t/date-type-on-custom-user-fields/47357/15 "2022-11-17T16:20:48Z")

</div>

我也会加入。我正在与一个致力于实现基于年龄的人生目标的社区合作，所以让他们获得年龄（他们愿意假装输入的任何年龄都是准确的）很重要。

这似乎是一个解决方案：[Datepicker in a User Custom field - #5 by tshenry](https://meta.discourse.org/t/datepicker-in-a-custom-user-field/83550/5?u=pfaffman)

但是添加一个用户自定义字段日期类型会容易得多。我很惊讶没有企业用户想要这个。将其添加到核心似乎并不难。你已经在 handlebars 中使用了 `DateTimeInputRange`，所以在 Rails 端添加它应该也很简单。

---

<div class="post-metadata">

### Author: ![chapoi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chapoi/32/537252_2.png) [@chapoi](https://meta.discourse.org/u/chapoi)
#### Post date: [2026年二月19日 06:05 UTC](https://meta.discourse.org/t/date-type-on-custom-user-fields/47357/16 "2026-02-19T06:05:16Z")

</div>

好吧，我们花了整整 10 年，但俗话说“_好东西值得等待_”不是吗？

> <https://github.com/discourse/discourse/pull/37902>
>
> Adds a new "date" field type to custom user fields, with native datepicker (ligh…tweight solution)
> 
> Long standing meta request: https://meta.discourse.org/t/date-type-on-custom-user-fields/47357 
> 
> \<img width="912" height="496" alt="CleanShot 2026-02-18 at 22 25 04@2x" src="https://github.com/user-attachments/assets/5e08091c-eee3-4580-a868-c3ead4422a92" /\>
> \<img width="970" height="1098" alt="CleanShot 2026-02-18 at 22 23 57@2x" src="https://github.com/user-attachments/assets/0c026d62-fe9c-4fe0-b057-8d392ce03b13" /\>
> \<img width="1034" height="236" alt="CleanShot 2026-02-18 at 22 24 43@2x" src="https://github.com/user-attachments/assets/d4264c6d-021a-4662-bd7a-7e89b48796df" /\>

孩子们，尽情享受吧。

---

<div class="post-metadata">

### Author: ![chapoi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chapoi/32/537252_2.png) [@chapoi](https://meta.discourse.org/u/chapoi)
#### Post date: [2026年三月21日 06:05 UTC](https://meta.discourse.org/t/date-type-on-custom-user-fields/47357/17 "2026-03-21T06:05:33Z")

</div>

此主题在最后回复后 30 天自动关闭。不再允许回复。
