Problem linking Discourse forum to WP Discourse

Hello,

I’m working on a wordpress site and have the WP Discourse plugin installed. Our objective is obviously to sync our wordpress site with the Discourse forum so that when a post is published to the site it is also published to Discourse.

However until now it didn’t work much. While creating a post, even with the “Create new Topic” Discourse box checked, it does not work and the post isn’t created in the forum.

I went to the WP Discourse plugin settings and to me everything seemed to be fine (everything isn’t obviously fine and I may have done something wrong as it doesn’t work), the Discourse API key is correct as well as the SSO secret key, as I’m also trying to use my wordpress site as an SSO provider.

I noticed in the WP Discourse plugin settings that there were two error messages, when accessing the “SSO Provider” and “Connection” tabs:


which is quite problematic because there IS an admin user with this email address on the forum (myself).
and most importantly, “You are not connected to Discourse. If you are setting up the plugin, this notice should go away after completing the form on this page.”

Soooo my wordpress and Discourse don’t seem to be synced. Can I please get some help in order to solve this ? Feel free to ask if you need more information - I guess you obviously do

The first thing to sort out is the issue on the Connections tab. The plugin won’t work until you establish a connection with Discourse.

What have you set for the Publishing Username on that tab? It should be set to either the Discourse username of the system user (‘system’ by default) or the username of an admin user from your forum.

What version of WordPress are you using?

3 Likes

Hello Simon, thanks for the answer.

So it seems really dumb, but as expected the Publishing Username wasn’t correct (I missed a space on the name). I fixed this and now I have the “You are connected to Discourse!” message.

Also no more error message on the SSO Provider tab. By the way I’m using WordPress 4.9.3.

Anyway, sorry for the inconvenience and thanks again for the answer. I’ll update this thread/create another one if I have any other issue especially with synchronizing the creation of posts between Wordpress and the forum.

3 Likes

Hi,

Although I put all the needed info to Connection tab but it still shows

You are not connected to Discourse. If you are setting up the plugin, this notice should go away after completing the form on this page.

Please help.

Discourse: https://forum.biohack.vn
WP: https://biohack.vn
I use admin as the username since it’s the Discourse admin.

Try using ‘system’ for the username.

1 Like

Already before I switch to admin.

For the Publishing Username setting, you need to use the username of your Discourse System user. That username defaults to ‘system’ (without the quotes.) For the API Key, use the All Users API Key. You can find that key at /admin/api/keys.

When I try to visit your site at http://biohackplus.com/, the page isn’t loading for me. Are you able to access it at that URL?

Let’s not open more than one topic on the same exact thing please.

2 Likes

I was able to connect to Discourse. However, although I put all the needed info Publishing tab, when I create a post in Wordpress, it doesn’t show in Discourse.

What I’m trying to do: When I create a post in a category in Wordpress, the plugin will create a post in Discourse with link to my Wordpress post in a matched Discourse Category.

This topic has instructions for publishing posts to Discourse: WP Discourse supports the WordPress Block Editor. Is this working for you?

1 Like

My site has a similar problem. I installed WP Discourse, created an all user key and the publishing username is system. And I still see “You are not connected to Discourse…” My site is proxied by Cloudflare but that is working correctly as far as I can tell. Any help really appreciated. Discourse is 2.6.0.b4.

Hey there @sturdy2, there’s a few reasons why you might be having an issue there. Could you try this configuration for me.

In Discourse: Create a global api key for an admin user

The config should look like this

In Wordpress: Use that key and set the “Publishing username” as the admin user you selected

(your “Discourse URL” field should have your discourse url, not what you see in the screenshot)

1 Like

Hi @angus , thanks for the response. Unfortunately, after creating the single user key as you stated, I still get the no connection message. I’ve tried everything I can think of but no joy…thanks again.

Ok, let’s see if we can figure it out.

Just to confirm, you created a “Global Key” (allows all actions)?

Assuming you did, let’s check the following:

  1. Where is your Discourse hosted? Where is your Wordpress hosted?

  2. Do you have any custom Discourse plugins installed?

  3. Please install this healthcheck plugin on wordpress:

    • Does this plugin detect any critical issues?

    • Enable Troubleshooting mode and only enable the wp-disocurse plugin (all other plugins will be disabled). Then try to connect again.

1 Like

Yes, Global, single user (myself, admin). WP Discourse does not connect.

  1. Discourse hosted by DO
  2. Not sure about custom plugins. Installed_Plugins
    3a. Health Check & Troubleshooting (aka Site Check) has been installed for some time. One questionable “critical issue” reported by Yoast SEO is “Your site cannot be found by search engines.” Further troubleshooting instructions state that “if Google can run the Mobile-Friendly Test, Google can also crawl the domain. In that case, the Ryte warning is wrong.” Both domain and subdomain pass the test.
    3b. Tried this previously and once again. All plugins except WP Discourse disabled. WP Discourse does not connect.

UPDATE: I’ve been playing with this for several days and there are several things I don’t understand, probably because almost all of this is totally new to me.

  1. The DNS “A” record for discourse subdomain points to the IP assigned by DO (same IP I use for SSH) but dig discourse.example.com points to three different IP apparently asssigned by Cloudflare and dig https://discourse.example.com points to another IP whois BAREFRUIT-ERRORHANDLING in GB. Something doesn’t smell right here!

  2. I assume WP Discourse uses cURL to connect with Discourse so I have been experimenting with cURL and the Discourse API. I have three API keys (including the key confirmed, above). Until yesterday all three indicated Never Used. Yesterday, I noticed the original key created last August now indicates it was used one day ago! The other two still indicate Never Used. I assume this likely means that one or more of my cURL experiments actually did connect; unfortunately, I don’t know which actually worked. I have also noted that cURL commands that produce http 200 do not change the API Last Used info (remains Never Used).

Both #1 and #2, above, seem important to me but I can’t yet determine the issues.

I apologize for the delay; sometimes life interferes. Again, @angus, thanks for your assist.

Ok, could you try removing Cloudflare from your setup. We need to narrow down the potential sources of error.

1 Like

Hi @angus,
Another update: I installed the Query Monitor plugin (in WP)(see output, below).

Using cURL at my local computer, I also get a 403 so it seems to me this is an upstream issue my site ans WP Discourse. Probably Cloudflare but I don’t want to remove Cloudflare yet. See below.

Another apology for my slowness. I have received a notice from my hosting service that my site is being migrated to another server and there will be some changes, including a change of IP. So I need to delay further work on this problem. May I call on you again when the dust settles?

EDIT: Solved! Perhaps a bug at /admin/site_settings/category/security -> allowed crawler user agents.
It appears that any entry in the allow UA text actually causes a block of all, even a curl command line from my local computer. Resetting the text to empty immediately results in WP Discourse " You are connected to Discourse!

3 Likes

Glad you figured it out! :tada:

Yes, that setting is intended to be quite restrictive I believe (hence the ALL CAPS warning in the instructions).

To allow your wordpress instance through while using allowed crawler user agents, you can add it like so:

Wordpress/<wordpress_version>

I just tested this out on my test Wordpress / Discourse by adding Wordpress/5.5.3 to allowed crawler user agents and it worked :+1:

If you don’t want to keep updating that every time you upgrade your wordpress you can use a simple plugin to set your own user agent for these type of requests in Wordpress, e.g.

https://github.com/webdeveric/wp-user-agent

2 Likes

Thanks for the explanation. This is starting to make more sense to me. I initially thought “allowed crawler user agents” was meant to identify allowed search engine crawlers. I initially entered “Googlebot” not understanding that WP Discourse used a Wordpress User Agent and became disallowed. Just one more newbie mistake. I should think this is a common misunderstanding but I found nothing in the limited documentation and more limited examples.

As “allowed crawler user agents,” I am now using Wordpress ( version not needed), Googlebot, and Discourse (added for use with cURL as below. Do You see a problem? Or do I need to add others?

Seems similar with cURL using Discourse API. I previously received 403 until I added the user agent as below.

First example published in Discourse API document (doesn't work for me):
curl -X GET "http://127.0.0.1:3000/admin/users/list/active.json" \
-H "Api-Key: 714552c6148e1617aeab526d0606184b94a80ec048fc09894ff1a72b740c5f19" \
-H "Api-Username: system"
This works for me after adding the user agent option.
curl -A Discourse -X GET "http://discourse.example/admin/users/list/active.json" \
-H "Api-Key: 714552c6148e1617aeab526d0606184b94a80ec048fc09894ff1a72b740c5f19" \
-H "Api-Username: system"

IMHO, examples shouldn’t be published unless they are complete and working…aargh.

@angus, many thanks for your help and assistance.

1 Like

Hi,

The only membership plugin that I know works with both WordPress and Discourse is Memberful. They also have detailed instructions on how to integrate with Discourse here – Integrate Discourse with Memberful | Memberful.com

If you are using any other Membership plugin already, it might be worth reaching out to them and asking them directly. I have used it in my client website portfolio is here.

2 Likes