# מספר אתרי Discourse על גבי WordPress אחד עם wp-discourse

**URL:** <https://meta.discourse.org/t/multiple-discourse-sites-on-single-wordpress-with-wp-discourse/270316>\
**Category:** Product Support\
**Tags:** wordpress\
**Created:** [2 ביולי,‏ 2023,‏ 5:42pm UTC](https://meta.discourse.org/t/multiple-discourse-sites-on-single-wordpress-with-wp-discourse/270316 "2023-07-02T17:42:55Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [2 ביולי,‏ 2023,‏ 9:13pm UTC](https://meta.discourse.org/t/multiple-discourse-sites-on-single-wordpress-with-wp-discourse/270316/3 "2023-07-02T21:13:18Z")

</div>

> [@pfaffman](#):
>
> Is there some way to have a single wordpress site that provides authentication for multiple Discourse sites?

The [WP Discourse](https://github.com/discourse/wp-discourse) plugin isn’t setup to handle this, but it should be possible.

> [@pfaffman](#):
>
> I tried copying the setup from the first Discourse site to the second one, but WordPress redirects to the first discourse site.

I’d start by adding a `site` URL parameter to the Discourse `discourse_connect_url` setting. On WordPress, use the `site` parameter to set the correct Discourse site to redirect to here:

> <https://github.com/discourse/wp-discourse/blob/main/lib/sso-provider/discourse-sso.php#L168>

You would probably also need to deal with the call to `sync_sso` that happens here: [wp-discourse/lib/sso-provider/discourse-sso.php at main · discourse/wp-discourse · GitHub](https://github.com/discourse/wp-discourse/blob/main/lib/sso-provider/discourse-sso.php#L45)

I’m not certain about this, but you might need to add `site` to the allowed query vars in this function (so that WordPress doesn’t remove the parameter): [wp-discourse/lib/sso-provider/discourse-sso.php at main · discourse/wp-discourse · GitHub](https://github.com/discourse/wp-discourse/blob/main/lib/sso-provider/discourse-sso.php#L45)

Ideally the above changes could be accomplished with `action` and `filter` hooks on WordPress. It looks like hooks would need to be added to the code for that.

I’m assuming that the spec for this doesn’t involve publishing posts from WordPress to multiple Discourse sites. If that’s the case, the required changes would be a little more involved.

I’ll let you know if I think of any other issues.

Edit: need to think about how the Discourse user id is used on WordPress to make sure there won’t be any conflicts between multiple sites - a single user on WordPress could potentially have accounts on multiple WordPress sites. They would have a different Discourse user id on each site.

Edit: the biggest issue I can see is if the “Create or Sync Discourse Users on Login” setting is enabled on the WordPress sites. It makes an API call to the Discourse `sync_sso` route. You’d need to have a way of knowing which Discourse site to sync or create the user on. You’d also need to have a Discourse API key for each site. This seems doable, but would add some complexity.

---

_[View the full topic](https://meta.discourse.org/t/multiple-discourse-sites-on-single-wordpress-with-wp-discourse/270316)._
