# WordPress multi-language site (As SSO Provider) with use locale Discourse instances

**URL:** https://meta.discourse.org/t/wordpress-multi-language-site-as-sso-provider-with-use-locale-discourse-instances/107491
**Category:** WordPress
**Created:** [January 25, 2019, 2:39am UTC](https://meta.discourse.org/t/wordpress-multi-language-site-as-sso-provider-with-use-locale-discourse-instances/107491 "2019-01-25T02:39:22Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Umashankar\_Ankuri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/umashankar_ankuri/32/150996_2.png) [@Umashankar\_Ankuri](https://meta.discourse.org/u/Umashankar_Ankuri)
#### Post date: [January 25, 2019, 2:39am UTC](https://meta.discourse.org/t/wordpress-multi-language-site-as-sso-provider-with-use-locale-discourse-instances/107491/1 "2019-01-25T02:39:22Z")

</div>

Hi @simon

Can a multi language WordPress site (WordPress as a SSO provider) be connected to different user locale discourse instances. ([en.community.domain.com](http://en.community.domain.com) / [fr.community.domain.com](http://fr.community.domain.com)). Any pointers on the setup?

I’m just referring to this multi- language options on the topic

> [@Best practice to managing a multi-language community?](https://meta.discourse.org/t/best-practice-to-managing-a-multi-language-community/34664):
>
> Hello everyone! There has been some discussion about how to manage a multi-language community. Like [this](https://meta.discourse.org/t/different-languages-per-forum/6995), [this](https://meta.discourse.org/t/user-configurable-ui-language-locale/8269) and [this](https://meta.discourse.org/t/make-a-multi-language-forum/18501). From what I’ve gathered there are 3 options for running a multi-language community: 1. Separate sites for every language. Pros Categories are preserved in every language. Users see only their native language. Cons Communities are separated with little to zero interaction. 2. Make a category for every language Pros Language communities interact. Multi-language spea…

Thank you.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [January 25, 2019, 3:40am UTC](https://meta.discourse.org/t/wordpress-multi-language-site-as-sso-provider-with-use-locale-discourse-instances/107491/2 "2019-01-25T03:40:02Z")

</div>

> [@Umashankar\_Ankuri](#):
>
> Can a multi language WordPress site (WordPress as a SSO provider) be connected to different user locale discourse instances.

One way I think this could work is if the WordPress site is using a multi-site setup. Each subsite can connect to its own Discourse instance. On a single-site WordPress setup, it is only possible to connect to a single Discourse forum.

Another possible approach would be to use a single Discourse forum, and give each locale its own category. You could log users into the correct category from WordPress.

With SSO it is now possible to set the user’s locale. The WordPress plugin has a filter that can be used for adding the locale to the SSO payload.

---

<div class="post-metadata">

### Author: ![Umashankar\_Ankuri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/umashankar_ankuri/32/150996_2.png) [@Umashankar\_Ankuri](https://meta.discourse.org/u/Umashankar_Ankuri)
#### Post date: [January 25, 2019, 4:09pm UTC](https://meta.discourse.org/t/wordpress-multi-language-site-as-sso-provider-with-use-locale-discourse-instances/107491/3 "2019-01-25T16:09:49Z")

</div>

> [@simon](#):
>
> now possible to set the user’s locale

Thanks @simon this helps.

---

<div class="post-metadata">

### Author: ![Umashankar\_Ankuri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/umashankar_ankuri/32/150996_2.png) [@Umashankar\_Ankuri](https://meta.discourse.org/u/Umashankar_Ankuri)
#### Post date: [January 31, 2019, 3:36pm UTC](https://meta.discourse.org/t/wordpress-multi-language-site-as-sso-provider-with-use-locale-discourse-instances/107491/4 "2019-01-31T15:36:39Z")

</div>

Hi Simon,

I’m able to find the filter for adding sso params, is this the right one to add? we want to use web page language as locale

```plaintext
add_filter( 'wpdc_sso_params', 'wpdc_custom_sso_params' );
function wpdc_custom_sso_params( $params) {
    $params['locale'] = get_locale(); // what ever language
    return $params;
}

```

Also I didn’t find filter to force login user to particular discourse url, please point me to right filter.

Thank you.

Regards,  
Umashankar

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [January 31, 2019, 6:52pm UTC](https://meta.discourse.org/t/wordpress-multi-language-site-as-sso-provider-with-use-locale-discourse-instances/107491/5 "2019-01-31T18:52:57Z")

</div>

> [@Umashankar\_Ankuri](#):
>
> I’m able to find the filter for adding sso params, is this the right one to add

Yes, that is the correct filter. For updating the locale of users who already exist on your system, you also need to pass the `locale_force_update` parameter. This code example will update a user’s locale to ‘fr’:

```plaintext
add_filter( 'wpdc_sso_params', 'wpdc_custom_sso_params' );
function wpdc_custom_sso_params( $params) {
    $params['locale_force_update'] = 'true';
	$params['locale'] = 'fr';

	return $params;
}

```

The WordPress `get_locale()` function is going to be unreliable to use for this. On my site that function returns `"en_CA"`. Discourse doesn’t accept this as a valid locale. It wants the string `"en"`.

Here’s the full list of locales that Discourse will accept:

```plaintext
ar, bg, bs_BA, ca, cs, da, de, el, en, es, et, fa_IR, fi, fr, gl, he, hu, id, it, ja, ko, lt, lv, nb_NO, nl, pl_PL, pt, pt_BR, ro, ru, sk, sl, sq, sr, sv, sw, te, th, tr_TR, uk, ur, vi, zh_CN, zh_TW

```

> [@Umashankar\_Ankuri](#):
>
> Also I didn’t find filter to force login user to particular discourse url,

I think what you want is a URL in this form:

```plaintext
<a href="https://forum.example.com/session/sso?return_path=https://forum.example.com/your-discourse-endpoint">Link Text</a>

```

The user will be taken to the URL set in the `return_path` parameter. Let me know if that isn’t what you are looking for.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [March 2, 2019, 6:52pm UTC](https://meta.discourse.org/t/wordpress-multi-language-site-as-sso-provider-with-use-locale-discourse-instances/107491/6 "2019-03-02T18:52:58Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
