Discourse WordPress plugin does not auto login user on alias domain

AI-generated summary

The Discourse WordPress plugin is not auto-logging users in when accessing the community via an alias domain. Himanshu_Singh has a WordPress site (abc.com) with a Discourse community hosted on community.abc.com. They’ve created a domain alias (abc.client.com) for a white label solution, but when users log in to abc.client.com and try to access the community, they’re redirected to abc.com/login instead of being auto-logged in. angus suggests that the issue might be due to the discourse connect url site setting being set to abc.com. Himanshu_Singh explains that they need to keep multiple domains for different partners and wonders if it’s possible to dynamically set the discourse connect url based on the site URL used to log in to WordPress. angus replies that this would require building a custom Discourse plugin.

Hello everyone,
We have a WordPress customization scenario that is breaking Discourse plugin functionality.

Scenario

  1. My site is WordPress site. Let’s say abc.com
  2. I have Discourse WordPress plugin installed and it works just fine to login to Discourse after I have logged into WordPress. I have to just click on the login button on Discourse and the user is auto logged in.
  3. The community is hosted on community.abc.com
  4. Now I have created a domain alias for my site as a white label solution for one of my client. Let’s say the new domain is abc.client.com
  5. This new domain allows the client to access the site in a completely white label manner. We don’t want then to access any content via the abc.com domain.
  6. Now, when the user from the client side logs in to abc.client.com (wordpress white label site), and then clicks on the community link, they are directed to community.abc.com.
  7. When the user clicks on login button on the community they are not auto logged in to the discourse site, and instead the page is redirected to abc.com/login/?redirect_to=%2Flogin%3Fsso…
  8. This redirection is not desirable as user would have to login to abc.com and then only access community.abc.com
  9. Question – is there a way to login to the discourse community after the user logs in to abc.client.com ?

This might be an issue related to the change in webhook as the domain alias used. Is there a workaround to make it happen? Does the user have to logged into abc.com to be logged in to the discourse community? Can there be two domains that login to the same Discourse community?

Appreciate your support.

Hello @Himanshu_Singh.

Firstly, I’m a little confused as to why you don’t just change the domain abc.com to abc.client.com? Why do you need two domains?

Secondly,

The redirect link is determined by your discourse connect url site setting on community.abc.com which I’m guessing is still set to abc.com.

@angus Good

Good question – we are building multiple white label solutions for different partners so we will have multiple partner urls (abc.client1.com, abc.client2.com, and so on) while also keeping our main url for direct business (abc.com). Think of these partners as affiliates who could use our product in their daily operations.

Is there a way to dynamically set discourse connect url based on the site url used to login to WP?

Thanks.

You’d need to build a Discourse plugin to do this.