WP Discourse SSO Plugin

(etc) #1

Piggybacking off the magnificent work of @AdamCapriola and @ArmedGuy, I’ve cleaned up and refactored the code into a WordPress plugin to normalize the setup procedure.

I want a few more people to test it before I submit it to the public repo. I’ve created a composer project out of it, however, so you should be able to install it as a wp dependency easily by using a stack like Bedrock.

Setup is simple:

  1. Install the plugin.
  2. Generate a random string to use as the secret key.
  3. Copy this secret key and your Discourse board’s URL to the settings page in your WP admin backend.
  4. Copy the url to your WP installation, as well as the secret key into the appropriate settings on your Discourse board as described here:

Voila - you should have proper SSO integration. Please let me know about any issues.


SSO locked me out of Discourse!
Laravel SSO and pre-registration
WordPress SSO Page Template
(etc) #2

I’ve released a new version of the plugin that factors out the template method that was used previously. This vastly simplifies the plugin and setup, now making it just a two step process. I’ve submitted it to the WP Repo, but until then, you can include it as a packagist lib.

"primetimecode/pt-wp-discourse-sso": "*";



After activating the plugin, I am getting a response “Click” and then I am unable to access anything, the WP Admin does not show anything except this message.

Found out that there is issue with “class-pt-wp-discourse-sso.php” on line 105
Click here to configure the WP + Discourse SSO plugins.

Commenting this out solves the issue and the plugin loads.



What should be used as page template for SSO url in WP. Not getting any new template while adding page

Kindly also suggest where are the screenshots as mentioned in readme file.

(etc) #5

Sorry, you must have gotten to it while I was in the middle of pushing some commits. The template system is no longer used. I need to remove that from the README as well. Please try downloading a new version and let me know if you still have problems.

(etc) #6

I’ve updated the instructions in the first post to better reflect the current setup process.


Thanks, But the issues persists.

A) After activating plugin my WP admin got stuck with "Setting up your WP + Discourse SSO connection is easy!

  1. " and then nothing.

B) It seems that on line 112 on “class-pt-wp-discourse-sso.php”, when you start the list there is some issue / error with $this->configured … or one of the plugin is causing issues with it.

C) "WIll the blog url be the sso url in discourse settings ? " , I used the blog url

D) When i try to login from discourse, it took me to WP login page, I logged in with authenticated user and got a white screen with error message “Account login timed out, please try logging in again”, then it never worked. I kept on getting login screen.

E) If I login in Wordpress first and then go to the Discourse url, It does not login, keeps me directing to wp login page, and my login is never authenticated.

Kindly check these issues at your end. Thanks.

(etc) #8

These issues don’t exist on my end, and haven’t been reported by anyone else. Are you getting any php errors?

  1. Just figured this out and kindly add this to your documentation that "Staff must approve all new user accounts before they are allowed to access the site. " should be unchecked for this plugin to work.

  2. If i am already logged in WP, but not in discourse, I have to re-login and enter my password, can’t this be seemless.

  3. But line 112 issue on error message still persists

(etc) #10
  1. That should not be the case. It seems like something is wrong in your configuration.
  2. I need an error to go on. I cannot replicate this issue, and no one else has reported it.



But if i am already logged in WP and try login with discourse then a I redirected to WP login page and it also does not login, maybe some of my local security plugin may be causing such an issue.

(etc) #14

I think i figured out what might be the issue. You are likely running PHP 5.2, which broke when I used an anonymous function. This has been remedied, and I’ve tested it against a 5.2 based installation. Let me know what the outcome is for you.

(Kane York) #15

There should be a Discourse-side admin warning for this, I’m noticing several people messing that up.

(etc) #16

Just FYI: I’ve released this to the WordPress repo, so it should be available within WP and wpackagist.

(Anoop Agarwal) #17

I have activated the WP discourse SSO plugin and done the necessary settings. But even after that, the problem is that once I log in the WP site, I am not automatically logged in the discourse site.
Also, I want to log out of the discourse site automatically once I log out of the WP site.
Kindly help me out.

(etc) #18

@myselfaka I think you might be confused on how it works. When you use the SSO option, Discourse will forward to the WP installation for authentication. If you’re already logged in, that should bounce you right back to the Discourse installation, but you’ll still need to click log in.

Unfortunately, an auto log out that’s not something that can be handled with a WordPress only plugin. That’d require a separate plugin for Discourse as well.

Neither of these behaviors is something I can remedy on the WordPress side.

(etc) #19

Nevermind - I just read your edits. That actually might be possible. If you want to add the request of logging out on the Discourse side when you log out on the WP side, I’ll look into it.

Just add an issue on the github repo.

Note: I will not be able to do as you said before - log you out of WP when you log out of Discourse.

(Matt) #20

Hi @etc -
I’d like to use the plugin with my Wordpress Multi Site. Each of the sites all go with the same Discourse site.
Is this possible?
The question/problem I’m having is what to put for the SSO url endpoint. It works fine for one of the multisites but how would I have it take the user to the appropriate site if it is not the one listed as the SSO url endpoint?

Thank you!

(etc) #21

With most multisite setups, the users are all members of the “primary blog,” so you’d use it for authentication. However, if you’re talking about having a separate setup of users from each sub-site, I don’t know if that’s possible. There wouldn’t really be a way to program in the “intuition” of which site they would have to log in to. The best we could probably do would be to have a Discourse plugin that added a dropdown of your multisites, and would send you to that endpoint accordingly.

Can you tell me what your use case is and why you can’t use the primary site?

(Kyler Boudreau) #22

Hey I’m brand new to Discourse, and this plugin sounds like the PERFECT solution for a SSO with my WordPress site. Is this currently still the way to go for that? My new Discourse install was just created today, and I’m just at the doorway of figuring stuff out. Thanks!