# DiscourseConnect and user time zone / location

**URL:** <https://meta.discourse.org/t/discourseconnect-and-user-time-zone-location/221461>\
**Category:** WordPress\
**Created:** [March 19, 2022, 10:38pm 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:** 3

<div class="post-metadata">

**Author:** ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)\
**Post date:** [March 22, 2022, 7:50am UTC](https://meta.discourse.org/t/discourseconnect-and-user-time-zone-location/221461/3 "2022-03-22T07:50:13Z")

</div>

Hey @troygrady, sorry about the slow reply (I field questions on the [WP Discourse](https://github.com/discourse/wp-discourse) plugin). I’ll address the timezone and location settings separately (they’re unconnected).

### Timezone

> [@troygrady](#):
>
> We’re adding in the ability for users to adjust their time zone in Wordpress so that their own activity on our site displays in the local time

Could you just clarify if you mean that you want user’s activity to display to them in _their_ local time? If so, unlike in Wordpress, that’s currently the default in Discourse (without any use of [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true)), and will automatically update if not set by the user. For example, I recently went from the timezone `Australia/Perth` to `Europe/Oslo`. I haven’t touched the timezone setting in my profile here on meta, and it now reads

 ![Screenshot 2022-03-22 at 08.33.55](https://global.discourse-cdn.com/meta/original/3X/3/f/3ff5534cd5d8bbbad8a77fb703990cfe74a87ba2.png)

Do you want behaviour different from this?

### Location

You can sync a location set in a Wordpress user profile with the location field in the user’s profile on Discourse. It doesn’t sync by default as there isn’t a standard field in Wordpress that’s equivalent to the location field in Discourse. You need to add some code in here. In your theme’s `functions.php` file or another spot you can add code, you need to add something like following, the key bit using the use of the `wpdc_sso_params` filter.

```php
function sync_discourse_location( $params, $user ) {
    $location = get_user_meta( $user->ID, 'user_location_meta', true );
    if ( $location ) {
        $params['location'] = $location;
    }
    return $params;
}
add_filter( 'wpdc_sso_params', 'sync_discourse_location', 10, 2 );

```

Note that you’ll need to substitute ‘user\_location\_meta’ with whatever user meta field is being used to store the user’s location on your Wordpress instance (i.e. whatever field is being used by the plugin you’re using to add user locations to Wordpress).

Also note that the Discourse location field is just a “string” field, which means that it will just display whatever is put into it literally. It has no affect on the user’s timezone and is not a geolocation (i.e. connected with mapping in any way).

---

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