# API 按关联账户 ID 获取用户

**URL:** https://meta.discourse.org/t/api-get-user-by-associated-account-id/184812
**Category:** Support
**Created:** [2021年三月30日 02:56 UTC](https://meta.discourse.org/t/api-get-user-by-associated-account-id/184812 "2021-03-30T02:56:58Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Mark\_Schmucker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mark_schmucker/32/124810_2.png) [@Mark\_Schmucker](https://meta.discourse.org/u/Mark_Schmucker)
#### Post date: [2021年三月30日 08:27 UTC](https://meta.discourse.org/t/api-get-user-by-associated-account-id/184812/2 "2021-03-30T08:27:48Z")

</div>

我也想这样做。我目前没有答案，但可以参考以下内容：

> [@Migrate FROM discourse](https://meta.discourse.org/t/migrate-from-discourse/178941/2):
>
> The Discourse user’s external\_id will match the WP user\_id.

> [@Migrate FROM discourse](https://meta.discourse.org/t/migrate-from-discourse/178941/11):
>
> I’m not interested in migrating from Discourse, but I am interested in this. Can you elaborate where this field is found? Using [Data Explorer](https://meta.discourse.org/t/32566?silent=true), I don’t see it under the users table or any other table.

> [@Migrate FROM discourse](https://meta.discourse.org/t/migrate-from-discourse/178941/12):
>
> I’m not sure in which table it’s stored, but external\_id is part of the users export file from /admin/users/list/active → Export EDIT: found it - it’s in the single\_sign\_on\_records table.

你可以从 /admin/users/list/active 页面下载包含用户 ID 和外部 ID 的 CSV 文件（点击“导出”）。这并非通过 API 调用获取，但或许会有所帮助。

---

_[View the full topic](https://meta.discourse.org/t/api-get-user-by-associated-account-id/184812)._
