# 是否为每个用户创建了唯一的用户ID，如何访问该变量

**URL:** <https://meta.discourse.org/t/is-a-unique-user-id-created-for-each-user-how-to-access-the-variable/188823>\
**Category:** Support\
**Created:** [2021年五月1日 18:35 UTC](https://meta.discourse.org/t/is-a-unique-user-id-created-for-each-user-how-to-access-the-variable/188823 "2021-05-01T18:35:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_King1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/paul_king1/32/218888_2.png) [@Paul\_King1](https://meta.discourse.org/u/Paul_King1)\
**Post date:** [2021年五月1日 18:35 UTC](https://meta.discourse.org/t/is-a-unique-user-id-created-for-each-user-how-to-access-the-variable/188823/1 "2021-05-01T18:35:54Z")

</div>

当在 Discourse 中创建新用户时，是否会分配一个唯一 ID？如果是，我该如何访问该变量？

我需要能够获取唯一 ID，例如 `<%= current_user.id %>`（我刚才只是编了一个例子，不确定是否正确，只是想说明我需要的变量形式）。

我需要它用于 Intercom 实时聊天，以便即使用户更改了邮箱，我仍能识别该用户。

请帮忙！🙏🙏🙏 谢谢

---

<div class="post-metadata">

**Author:** ![ykcorner](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ykcorner/32/217259_2.png) [@ykcorner](https://meta.discourse.org/u/ykcorner)\
**Post date:** [2021年五月1日 20:04 UTC](https://meta.discourse.org/t/is-a-unique-user-id-created-for-each-user-how-to-access-the-variable/188823/2 "2021-05-01T20:04:12Z")

</div>

不确定它会在哪些区域显示，但如果您进入管理面板 → 用户 → 选择某个用户，URL 中会显示该用户的 ID。例如：[domain.com/admin/users/](http://domain.com/admin/users/) **1** /username

---

<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:** [2021年五月2日 02:05 UTC](https://meta.discourse.org/t/is-a-unique-user-id-created-for-each-user-how-to-access-the-variable/188823/3 "2021-05-02T02:05:35Z")

</div>

你可以换一种方式，设置一个自定义字段。在外部输入中，所使用的 ID 应该是用户加载时的 ID，我认为是这样。
