WordPress as SSO Client in a Multisite Installation

(Andrew ) #1

1.4.0 27/06/2017

  • Add Discourse webhook endpoint for syncing Discourse topics with WordPress posts
  • Add a multisite configuration option for use when a single Discourse forum is connected to a network of WordPress sites

Would someone be willing to elaborate on the multisite config, and how it relates to SSO client (if at all)? I just upgraded to 1.4.0, and don’t see the new options at the network or individual site level.

Off to play with webhooks while I wait. :slight_smile:

WP Discourse plugin installation and setup
(Simon Cossar) #2

You won’t see those options unless you install the plugin in a multisite setup.

For a multisite setup, it only works with WordPress as the SSO Provider. Using it with WordPress as the SSO client is coming, but it’s not ready yet.

(Andrew ) #3

Thank you, I am running wordpress in multisite, and have been using wp-discourse on the install for about 2 years, so I am interested to see what this changes. Where should I look for the options? If the options don’t appear as expected, I’ll probably have to reinstall the plugin, but I’m hoping I’ve just looked over them.

(Simon Cossar) #4

There’s only one option to select. It should be available at the bottom of the Connection settings tab on the main site of the network. Can you take a look and see if it’s showing up for you? But don’t enable it just yet because of this:

My assumption was that no one had been using the plugin in a multisite setup. The difficulty with using webhooks with the multisite setup is associating a Discourse topic with a WordPress post. To get around this, when the Multisite Configuration option is selected, a database table is now being created that saves the blog_id/topic_id. This is used when the webhook data is received from Discourse to associate a topic with the correct blog. Without having the data in this table, it won’t be possible to update the old posts on your site with a webhook.

Can you describe your multisite setup a little more? Is it one Discourse forum associated with a network of sites?

(Andrew ) #5

It’s running on WP multisite, but I beliiiiieeeeeve only one of the subsites (not the main ID 1 site) has actively used it.

Okay, I do see the multisite config in the main site Connections under the Discourse tab. I had been looking in network admin, and the subsites… didn’t think to check ID 1 settings. The Discourse tab also shows on the other subsites, but without the multisite config checkbox.

I should also say that it’s not a huge deal (for me) if the old comments get unlinked. Basically all it has been doing is pushing the posts from WP to Discourse, but not really syncing the comments. So if this is an opportunity for a clean break from legacy to the new way, I am fine with that. However, I will await your instructions in case it’s not so simple.

(Simon Cossar) #6

Great! That’s how it should be. If you select the Multisite Configuration option the Connection settings (API key etc.), Webhook options, and Enable SSO options will be set for all your subsites off of the main site. It will also create the database table that’s used to associate posts with blog_ids.

If you don’t select the Multisite Configuration option, those settings can be made individually for each subsite. The best approach to take really depends on how many subsites you have. If you would like to use webhooks and you have 100 subsites, without selecting the Multisite Configuration option, you’d have to setup 100 webhooks. I don’t think that would be a great idea.

It’s quite late where I am. I’ll look at this in the morning and get back to you.

(Simon Cossar) #7

Yes, the way it’s setup now, that would be a problem. It’s only for the case of a single forum linked to a network of sites. It looks like it should be quite easy to add a filter to the plugin to allow the multisite configuration to be overridden for specific blog_ids.

(Simon Cossar) #8

If you don’t enable the Multisite Configuration option and don’t enable the Sync Comment Data Webhook on any of your subsites, everything should function on your sites in the same way as it did before this update.

If you don’t enable the Multisite Configuration option, you can enable the Sync Comment Data webhook individually for each subsite. You can enable it for some subsites and leave it disabled for others. You’ll need to add a webhook, using the correct Payload URL on Discourse, for each subsite that you’ve enabled. The subsite’s Payload URL is available in the Sync Comment Data Webhook setting description on each subsite. Doing this might make sense if you are publishing to different Discourse categories from each subsite, or if only one or two of your subsites were displaying Discourse comments.

It will be possible to do this after the next update. I’ve added a filter that you can hook into to exclude particular subsites from the multisite configuration. That update will be available in the next couple of days.

If you run into any issues with the plugin’s multisite functionality, please let me know.

(Andrew ) #9

I am now following up on this and trying to add 3 subsites to the multisite WP install. The plugin has gone through several updates since this conversation (it was at 1.4.x at the time). Currently, I have Discourse options on the Network Admin page and on Subsite Admin pages. Is this the expected behavior? In the context of our conversation some months ago, I now find myself thoroughly confused.

(Simon Cossar) #10

I’ll get back to you early next week about this.

(Andrew ) #11

No hurry. Thanks for all the work you put into this.

I’ll try to reduce the scope.


I am using Discourse as the SSO provider to WordPress. Currently, I have this set at the Network level in the plugin settings. This appears to be functioning as expected.

It seems that my current setup reflects the intended behavior. That is based on this note in the plugin options of the subsites:

You are using the WP Discourse plugin in a subsite of a multisite installation. The plugin’s API credentials are being managed through the installation’s main site. If you have difficulty connecting to the Discourse forum. Please contact the network administrator.

If that is correct, then my first observation is that there doesn’t seem to be a way to change the Publishing Username on the subsites. In my scenario, each subsite is owned by a separate Discourse user who is a human who wants to be associated with their blog posts. Ideally, each post they make from their subsite would be published to Discourse as their own username.


If I disable the multisite option in Network, the subsite Publishing Username reverts to the desired subsite behavior. However, the tab to put WP in SSO Client mode disappears. Does using Discourse as SSO Provider only work if Enable Multisite Configuration is selected in the Network settings? The SSO settings are still present in the Network UI when it isn’t selected.

In other words

As I alluded to initially, part of my confusion relates to our earlier discussion which included discussion of filters to exempt some subsites from the multisite config.

Is it possible to get these three behaviors simultaneously:

  1. Each subsite publishing to Discourse as Username of the subsite owner
  2. Discourse as SSO Provider for all WP subsites
  3. Advanced. One subsite publishing to an entirely different Discourse install