# （已退役）使用自定义用户字段中的ID链接到用户的外部资料

**URL:** <https://meta.discourse.org/t/retired-use-an-id-in-a-custom-user-field-to-link-to-a-users-external-profile/41218>\
**Category:** Site Management\
**Created:** [2016年三月17日 17:43 UTC](https://meta.discourse.org/t/retired-use-an-id-in-a-custom-user-field-to-link-to-a-users-external-profile/41218 "2016-03-17T17:43:28Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)\
**Post date:** [2016年三月20日 00:35 UTC](https://meta.discourse.org/t/retired-use-an-id-in-a-custom-user-field-to-link-to-a-users-external-profile/41218/11 "2016-03-20T00:35:39Z")

</div>

You will have to save the user `external_id` in custom field when creating SSO record. See example here:

> <https://github.com/discourse/discourse/blob/a3b2b4bacac92b0dc5ceaf6892f782f4b5584a57/spec/controllers/session_controller_spec.rb#L52-L57>

Or you can fill the custom user field via `sync_sso` method. For example:

```plaintext
client.sync_sso(
  sso_secret: "discourse_sso_secret",
  name: "Test Name",
  username: "test_name",
  email: "name@example.com",
  external_id: "2"
  custom.user_profile_id: "2"
)

```

Relevant [code here](https://github.com/discourse/discourse_api/blob/master/lib/discourse_api/api/sso.rb#L14-L16).

---

_[View the full topic](https://meta.discourse.org/t/retired-use-an-id-in-a-custom-user-field-to-link-to-a-users-external-profile/41218)._
