A few questions about WP Discourse

Hi!

I have a Wordpress blog which I connected to a Discourse forum through WP Discourse. WP Posts and comments are synchronized with Discourse through Discourse API.

About the SSO, from what I understand, two choices are given :

  1. Discourse authentication goes through WP. Users can’t log into Discourse by other means than through WP.
  2. WP authentication goes through WP or Discourse, the choice is given to the user (there is a “login with Discourse” link under the WP login form).

Question 1: Regarding the solution 2), is there any way to force WP users to login/create accounts through Discourse? By having an embedded Discourse login form instead of Wordpress login form or something like that… So all the users are managed by Discourse, which I would prefer.

Question 2: I didn’t try it yet, but with the solution 1) is it possible to use a WP plugin to allow users to log in through Facebook or other social media when being on the WP login form, and if they do this way it also creates a Discourse account?
From what I imagine, it would be: Facebook login creates a WP account -> Creation of a WP account which logs to Discourse too.
Basically, if a user wants to log in on Discourse or WP, they are redirected in both cases to the WP login form, which gives a choice: WP login (which creates a Discourse account thanks to SSO), or Facebook login (which does the same through WP… Am I clear ? :grin:)

Question 3: Actually, with WP Discourse, a synchronized WP post displays the post comments, but no comment form. Instead, there is a " Continue the discussion" link which leads to Discourse.
Is there any fairly simple way to the following things?

  • If the user is already logged in, show a text area which sends the content to Discourse through the API and redirects the user to the post discussion on Discourse
  • If the user isn’t logged in, show a login form which redirects somewhere after having logged in (on the WP post page or the post discussion on Discourse)

I’m not particularly afraid of having to do some PHP code, but I don’t know much about WP methods and stuff that I should use doing so.

Yes, just don’t give them access to the WordPress login form. You should setup a way to give your site’s admins access to it, so that they don’t get locked out of WordPress if your forum it down, or SSO is misconfigured. You can add the Discourse login link to any WordPress page with the [discourse_sso_client] shortcode, or by creating a link with this form. Set the link’s href to the Home URL of your WordPress site, set the redirect_to value to the WordPress page you want users to end up on. You can also add a link like this to your Discourse forum.

<a href="http://example.com/?discourse_sso=1&redirect_to=http://example.com/welcome">Log in with Discourse</a>

Yes, this should work if you are using WordPress as the SSO provider for Discourse. I’ve tested it quite a bit with wordpress.com as the authenticator for the WordPress site.

Yes, this can be done. It’s not a part of the plugin, because the idea behind the plugin is to improve commenting on WordPress pages. Discourse is designed to do this. Embedding a comment form would defeat that purpose for most cases.

The Discourse post_id and topic_id are saved as metadata on posts that are published to Discourse. You can use these values to publish to Discourse through the API.

4 Likes

Thank you very much for these replies!

Is there any way to embed a Discourse login form or is the only to way to log in to Discourse from WP is through a link which redirects to Discourse?

Could you explain me a bit what do you mean by this?

How displaying a comment form would not improve Wordpress commenting, if the forum data is sent to Discourse? What exactly do you mean by improving?

Being a part of the conversation. If someone just reads the post and then fires off a comment, they are less likely to have read the full topic than someone who goes to Discourse to make the comment. I’m sure there are valid use cases for it though.

I’m more interested in adding a form to WordPress to create a new Discourse topic. I think it could be useful for support forums.

3 Likes