Problem linking Discourse forum to WP Discourse

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

Hi folks. I too, am having issues connecting Wordpress (5.7.1) to Discourse (2.7.0.beta7).

I’ve installed the WP_Discourse plugin on another Wordpress site to hook into my Discourse forum. For some reason it refuses to connect even though the API is correct and set to all users as well as the admin username properly set.

The plugin does pull in the name and URL of the forum in other parts of it but it still says: " **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.*"

I also noticed since upgrading to the latest version of Discourse (I was a couple versions behind), on another WP site the plugin is no longer connected and when I try to reconnect it has the same issues above and is no longer connected.

I deactivated all WP plugins except for Discourse to see if it solved the issue, no go. Also checked security settings in Discourse to make sure I hadn’t inadvertently blocked all crawlers, etc. Not the issue.

I reissued Global APIs just in case. Natch. I also set up a global API just for my admin username and used that key, still natch.

Changed from my username to system as username, still no go.

Not sure what else I can do – how can I debug this further? Also, could it be a firewall issue? What ports are used?

Thanks,
Ray

P.S. I did recently change domains on the Discourse instance and followed the directions here. Everything else seems to be working fine.

Only other change is I recently updated Discourse from a couple versions behind to the latest.

UPDATE: On a hunch I rolled back the updated Discourse back to 2.7.0.beta3 and both of my Wordpress sites are able to connect to Discourse so I’m guessing there’s something in the updated versions of Discourse after 2.7.0.beta3 that might be causing issues?

UPDATE 2: I believe the issue has to do with changing domain names - I was finally able to update Discourse to the latest version and Wordpress was able to hook into it. However, each time I change the domain over, it fails. I’ll have to dig into it some more - I bet it has to do with a stray domain setting somewhere despite following the directions here to the letter.

UPDATE 3: Dug into the logs, I see I exceeded the rate limit for Let’s Encrypt so I’ll have to try again next week : /

Let me know how I can help debug this.

Ray

P.S. I tried to change the domain and do a rebuild without updating Discourse per this but for some reason the rebuild updates to the latest version so I’m unable to debug this further.

1 Like

Hey @Solari, sorry for the slow reply here I missed this somehow. I’ll respond in detail on Monday.

1 Like

No worries. I’m positive my issues are with exceeding the rate limit for SSL cert requests while testing the thing out. ; )

1 Like

Just to clarify, the WP Discourse Plugin has no issues with the latest Discourse. You can see the plugin working with a Discourse instance that is automatically updated to the latest Discourse version every 24 hours here: Wordpress - Try Pavilion. The Discourse it is connected to is here: wordpress.thepavilion.io

Apologies if you mentioned this, but just checking you’re also updating the Discourse URL in the WP Discourse plugin’s connection settings?

2 Likes