# DiscourseConnect 和用户时区/位置

**URL:** https://meta.discourse.org/t/discourseconnect-and-user-time-zone-location/221461
**Category:** WordPress
**Created:** [2022年三月19日 22:38 UTC](https://meta.discourse.org/t/discourseconnect-and-user-time-zone-location/221461 "2022-03-19T22:38:16Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![troygrady](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/troygrady/32/232574_2.png) [@troygrady](https://meta.discourse.org/u/troygrady)
#### Post date: [2022年三月22日 14:59 UTC](https://meta.discourse.org/t/discourseconnect-and-user-time-zone-location/221461/4 "2022-03-22T14:59:01Z")

</div>

谢谢 Angus！延迟没关系。

> [@angus](#):
>
> > [@troygrady](#):
> >
> > 我们正在添加一项功能，允许用户在 WordPress 中调整他们的时区，以便他们在我们网站上的活动以本地时间显示
> 
> 你能否澄清一下，你的意思是希望用户的活动以_他们_的本地时间显示？如果是这样，与 WordPress 不同，Discourse 目前默认就是这样。

抱歉造成困惑！是的，本地时区，是的，标准的 Discourse 行为很棒。正如你所指出的，问题不在于 Discourse，而在于 WP 没有能力让用户以本地时区查看网站。这就是我们想要添加的。如果我们让用户设置他们的时区，那么我认为我们也应该让该设置覆盖 Discourse 的设置，以便它们保持同步。这就是我想知道 [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) 是否提供的内容。听起来它不提供。

我_没有_意识到 Discourse 的设置是自动的。如果是这样，我们可能就保持原样。即，在 WP 中实现本地时区，而不让该值覆盖 Discourse 的值。是的，它们可能会不同步，但这可能对大多数用户来说并不是真正的问题。

> [@angus](#):
>
> 你可以将 WordPress 用户配置文件中设置的位置与 Discourse 中用户配置文件的位置字段同步。它不会默认同步，因为 WordPress 中没有与 Discourse 中的位置字段等效的标准字段。

太好了，这是缺失的信息——我不知道 [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) 应该从 WP 端的位置数据中获取什么。我们手动实现了自己的位置字段，在 usermeta 中，所以我们可以使用 wpdc\_sso\_params 钩子从中提取值。

我比较迟钝，所以可能忽略了。是否有关于 wpdc\_sso\_params 的文档？我找到了这个帖子，目前似乎涵盖了它：

> [@Map custom User Fields](https://meta.discourse.org/t/map-custom-user-fields/156164/7):
>
> You can update User Fields that you have created on Discourse via SSO. This does not require a plugin. To do this, you need to know the name that Discourse uses in the database for the custom field. The easiest way I know of to do this is by going to your Admin / Customize / User Fields page and then loading the JSON version of the page. For example https://forum.example.com/admin/customize/user\_fields.json The JSON data of the page will look something like this: { user\_fields: [ { id: 12, nam…

---

_[View the full topic](https://meta.discourse.org/t/discourseconnect-and-user-time-zone-location/221461)._
