The documentation for setting up the plugin in a multisite network is not up to date. This is a good chance to sort it out and update the WP Discourse plugin installation and setup guide.
To use the SSO client functionality on a multisite network, the plugin needs to be configured at a network level. That is done by clicking the Discourse link on your Network Dashboard:
On the Discourse network page, select the Enable Multisite Configuration option. Then enter your Discourse URL, API Key, and Publishing Username into the Connection Settings section. Scroll to the bottom of the page and click the Save Options button. You should see a ‘You are connected to Discourse!’ message at the top of the page.
To use Discourse as the SSO provider for site’s on your multisite network, scroll to the bottom of the Discourse network page and select the Enable SSO Client option. Also add a key to the SSO Secret Key setting. Save your options again.
Now go to your Discourse site and copy the secret key into the Discourse
sso provider secrets site setting. Enter a
* symbol as the SSO provider domain. When that setting has been saved, it should look similar to this:
Now select the
enable sso provider option on Discourse.
With these settings in place, going to the WP Discourse SSO / SSO Client tab for any sites on your network should take you to a page that looks similar to this:
For a quick test, select the Add Login Link and Sync Existing Users by Email options. Then logout of your WordPress site. You should be able to log back in by clicking the ‘Login with Discourse’ link that will be displayed on your
If you are not using the default WordPress login page, try copying the
[discourse_sso_client] shortcode into a post on your site. That shortcode only displays markup on the page for logged out users. You can also create a login link by constructing a link in this form:
<a href="https://example.com/?discourse_sso=1&redirect_to=https://example.comt/">Log in with Discourse</a>
That will log the user into your site with Discourse and then redirect them back to the WordPress page you have set as the value of the
Based on your debugging, it seems that the Enable SSO Client option was not enabled on your Discourse Network page. Can you make sure that option is enabled and let me know if you’re still having trouble with it?
The code you found that was preventing the SSO Client from working for you is correct, but is a badly written condition:
if ( empty( $this->options['sso-client-enabled'] ) || 1 !== intval( $this->options['sso-client-enabled'] ) )
It should be simplified to
if ( empty( $this->options['sso-client-enabled'] ) ). That’s the pattern that’s used everywhere else in the plugin.