WP Discourse plugin installation and setup


(Simon Cossar) #146

A post was merged into an existing topic: WP Discourse Plugin Tips and Tricks

(John) #147

I am using the Latest WP Discourse plugin with v2.1.0.beta4+16 and cannot seem to see created categories with Default Discourse Category. Not in the plugin->publishing tab or when posting in new blog post. The default user is system and the api is correct as it says connected in green color in the plugin->connection tab.

Anyone experiencing this or is there some setting in discourse to allow it being visible to the wp discourse plugin? I also generated an api for the system user and used that. There was an icon in the api link but i do not see the term ‘Generate Master API Key’ option in the api link.

(Simon Cossar) #148

If you have updated your categories on Discourse after installing the plugin, you will need to fetch them again by selecting the ‘Force Category Update’ setting on the WP Discourse Publishing tab. Can you let me know if that doesn’t solve your problem?

The way categories are being fetched by the plugin could use some improvement. I’ll see what can be done about this.

(John) #149

oh… this is embarassing. I didn’t even notice that option… Thanks for answering an obvious answer. Apologies.

(Simon Cossar) #150

Actually, thanks for bringing it up. I’ll do what I can to make it clearer.


I’ve problem with update-user webhook. It’s failed.

{"code":"rest_no_route","message":"No route was found matching the URL and request method","data":{"status":404}}

Any ideas?

(Simon Cossar) #152

The update-user webhook route will only be activated if your site is functioning as the SSO provider for Discourse. Are you using your site as the SSO Provider?


Oh, i will use SSO but i am not using now. I get the idea. Thanks.


On another topic, I’ll share a little thing :

On a wordpress running for a few years, I had trouble to connect Discourse and Wordpress. I had the error message “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.” even though everything was correct.

It is a wordpress on a shared hosting plan and it was stuck on a old version of php (5.4 if I remember correctly). I upgraded php via the hosting service (php 7.0 stable version), since then the connection works perfectly.

It was this topic who helped me identify the issue : Wordpress failure to connect to Discourse
curl wasn’t up to date before my php upgrade

The SSO Provider stuff worked before that, so it probably wasn’t a big deal, but this bugged me.

I lost too many time on this, so I wanted to share with others who might have this issue.

(Andy at Focallocal) #167

All working great now.

While i’m here, is it possible to include the title with the excerpt? and/or the header photo? i think that extra content would increase people clicking through to read the full article

(Simon Cossar) #168

Probably the easiest way to do what you are looking for is to customize the discourse_publish_format_html template so that it published the post as a onebox. Have a look at WP Discourse template customization for details about how to do that.

(John) #169

NM. seems my php process needed to be restarted(agressive caching settings) because my plugin changes. If anyone have problems with empty fields in the discourse connection tab.

(Andy at Focallocal) #170

a new bug just occurred. when logging in on discourse i get this error url come up:


and users can’t login.

(Simon Cossar) #171

Is this happening on every login, or does it just happen sometimes? Were any changes made on either your WordPress site or your Discourse forum before it started happening?

(Andy at Focallocal) #172

every time. i’m not sure what changed, it was around the time i upgraded wordpress to the latest version, and also the time i fixed the bot username with your kind help.

(Simon Cossar) #173

I don’t think anything has changed recently in the SSO code. Can you double-check all of your SSO settings? Which SSO setting are you using on WordPress, SSO Provider, or SSO Client?

(Danny Goodall) #174

@Simon_Cossar, I am trying to help a friend to move from the WP Foro forum to Discourse and would like to connect WP and Discourse using this plugin. I hope you can offer some advice as I’m really struggling to get past the…

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.

…message on the options page.

I’ve read all the threads on here that mention this message and have followed all of the advice that I have found but to no avail.

Any further advice or tests to run would be gratefully received.


My domain is managed by Cloudflare but only using DNS (no proxy).

Wordpress is on a shared host via TSOHost and the installation points to www.mydomain.org.uk. It is running over https using LetsEncrypt and the Really Simple SSL plugin.

Discourse is a brand new install (v2.2.0.beta2 +4) hosted at DigitalOcean. Discourse is using LetsEncrypt and is hung off the subdomain discourse.mydomain.org.uk.

The Symptoms

Discourse works as expected.

Wordpress also works as expected.

When I try to save the WP Discourse options I see the “You are not…” message.

The options that I am setting in the WP Discourse plugin are as follows.

Discourse URL: https://discourse.mydomain.org.uk

API Key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Publishing Username: system

Per your instructions on another thread, I have installed Query Monitor. It shows that when I try to save the options, the following error is returned to cURL.

cURL error 7: Failed to connect to discourse.mydomain.org.uk port 443: Connection refused

I have entered the Docker app and tail'd the Discourse access.log whilst saving the WP Discourse plugin settings and nothing appears in the log file. i.e. it seems that this attempt to connect does not make it as far as Docker.

What have I tried?

I initially had both Discourse and Wordpress running over http and have tried with Discourse over https and Wordpress over http and now both are running over https.

I’ve checked that the user ‘system’ exists.

The API Key has set to the global API Key which has been generated, re-generated and I’ve also tried generating a specific API Key for system user.

I am using the default created system user and have confirmed that it exists.

I’ve taken the manual URL that is being generated…


…and used it in a browser and it returns the results I would expect - as shown below:

{"user_badges":[{"id":1,"granted_at":"2018-09-14T20:21:42.750Z","count":1,"post_id":11,"post_number":1,"badge_id":41,"user_id":-1,"granted_by_id":-1,"topic_id":8}],"badges":[{"id":41,"name":"First Emoji","description":"Used an Emoji in a Post","grant_count":1,"allow_title":false,"multiple_grant":false,"icon":"fa-certificate","image":null,"listable":true,"enabled":true,"badge_grouping_id":1,"system":true,"slug":"first-emoji","manually_grantable":false,"badge_type_id":3}],"badge_types":[{"id":3,"name":"Bronze","sort_order":7}],"users":[{"id":-1,"username":"system","name":"system","avatar_template":"/user_avatar/discourse.mydomain.org.uk/system/{size}/2_1.png","moderator":true,"admin":true}],"topics":[{"id":8,"title":"Welcome to Discourse","fancy_title":"Welcome to Discourse","slug":"welcome-to-discourse","posts_count":1}],"user":{"id":-1,"username":"system","name":"system","avatar_template":"/user_avatar/discourse.mydomain.org.uk/system/{size}/2_1.png","email":"no_email","last_posted_at":"2018-09-15T03:30:59.278Z","last_seen_at":"2018-09-15T19:34:24.326Z","created_at":"2018-09-14T20:12:47.287Z","can_edit":true,"can_edit_username":true,"can_edit_email":true,"can_edit_name":true,"can_send_private_messages":true,"can_send_private_message_to_user":false,"trust_level":4,"moderator":true,"admin":true,"title":null,"uploaded_avatar_id":2,"badge_count":1,"has_title_badges":false,"custom_fields":{},"pending_count":0,"profile_view_count":4,"time_read":0,"recent_time_read":0,"primary_group_name":null,"primary_group_flair_url":null,"primary_group_flair_bg_color":null,"primary_group_flair_color":null,"staged":false,"second_factor_enabled":false,"second_factor_backup_enabled":false,"associated_accounts":[],"post_count":3,"can_be_deleted":false,"can_delete_all_posts":false,"locale":null,"muted_category_ids":[],"watched_tags":[],"watching_first_post_tags":[],"tracked_tags":[],"muted_tags":[],"tracked_category_ids":[],"watched_category_ids":[],"watched_first_post_category_ids":[],"system_avatar_upload_id":null,"system_avatar_template":"/letter_avatar_proxy/v2/letter/s/bcef8e/{size}.png","gravatar_avatar_upload_id":2,"gravatar_avatar_template":"/user_avatar/discourse.mydomain.org.uk/system/{size}/2_1.png","muted_usernames":[],"mailing_list_posts_per_day":0,"can_change_bio":true,"user_api_keys":null,"user_auth_tokens":[],"user_auth_token_logs":[],"invited_by":null,"groups":[],"group_users":[],"featured_user_badge_ids":[1],"user_option":{"user_id":-1,"email_always":false,"mailing_list_mode":false,"mailing_list_mode_frequency":1,"email_digests":true,"email_private_messages":false,"email_direct":false,"external_links_in_new_tab":false,"dynamic_favicon":false,"enable_quoting":true,"disable_jump_reply":false,"digest_after_minutes":10080,"automatically_unpin_topics":true,"auto_track_topics_after_msecs":240000,"notification_level_when_replying":2,"new_topic_duration_minutes":2880,"email_previous_replies":2,"email_in_reply_to":true,"like_notification_frequency":1,"include_tl0_in_digests":false,"theme_ids":[3],"theme_key_seq":0,"allow_private_messages":true,"homepage_id":null}}}

I have upgraded PHP from 5.x to 7.1.

Again, following your instructions I installed the TLS 1.2 Compatibility Test plugin. It yields the following results.

The curl values from the PHP Info plugin are as follows.

cURL support enabled
cURL Information 7.41.0
Age 3
AsynchDNS No
CharConv No
Debug No
GSS-Negotiate No
IPv6 Yes
krb4 No
Largefile Yes
libz Yes
Protocols dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtsp, smb, smbs, smtp, smtps, telnet, tftp
Host x86_64-unknown-linux-gnu
SSL Version OpenSSL/1.0.2a
ZLib Version 1.2.3

I’ve SSH’d into the Wordpress host and tried to curl to the Discourse installation from the bash shell.

curl -v https://discourse.mydomain.org.uk/users/system.json?api_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx&api_username=system

Whilst this succeeds, I can’t guarantee that it is the same user that WP is using and it is certainly at shell level and not from within PHP. Anyway, the message produced is…

* About to connect() to discourse.mydomain.org.uk port 443 (#0)
*   Trying connected
* Connected to discourse.mydomain.org.uk ( port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate:
* 	subject: CN=discourse.mydomain.org.uk
* 	start date: Sep 14 19:20:42 2018 GMT
* 	expire date: Dec 13 19:20:42 2018 GMT
* 	common name: discourse.mydomain.org.uk
* 	issuer: CN=Let's Encrypt Authority X3,O=Let's Encrypt,C=US
> GET /users/system.json?api_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: discourse.mydomain.org.uk
> Accept: */*
< HTTP/1.1 200 OK
< Server: nginx
< Date: Sat, 15 Sep 2018 19:38:37 GMT
< Content-Type: application/json; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Vary: Accept-Encoding
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< X-Download-Options: noopen
< X-Permitted-Cross-Domain-Policies: none
< Referrer-Policy: strict-origin-when-cross-origin
< X-Discourse-Username: system
< X-Discourse-Route: users/show
< Cache-Control: no-cache, no-store
< X-Request-Id: 3f9bb78d-d55d-4d63-a9ca-0726fa1e11c9
< X-Runtime: 0.176514
< Referrer-Policy: no-referrer-when-downgrade
< Strict-Transport-Security: max-age=31536000
{"user_badges":[{"id":1,"granted_at":"2018-09-14T20:21:42.750Z","count":1,"post_id":11,"post_number":1,"badge_id":41,"user_id":-1,"granted_by_id":-1,"topic_id":8}],"badges":[{"id":41,"name":"First Emoji","description":"Used an Emoji in a Post","grant_count":1,"allow_title":false,"multiple_grant":false,"icon":"fa-certificate","image":null,"listable":true,"enabled":true,"badge_grouping_id":1,"system":true,"slug":"first-emoji","manually_grantable":false,"badge_type_id":3}],"badge_types":[{"id":3,"name":"Bronze","sort_order":7}],"users":[{"id":-1,"username":"system","name":"system","avatar_template":"/user_avatar/discourse.mydomain.org.uk/system/{size}/2_1.png","moderator":true,"admin":true}],"topics":[{"id":8,"title":"Welcome to Discourse","fancy_title":"Welcome to Discourse","slug":"welcome-to-discourse","posts_count":1}],"user":{"id":-1,"username":"system","name":"system","avatar_template":"/user_avatar/discourse.mydomain.org.uk/system/{size}/2_1.png","email":"no_email","last_posted_at":"2018-09-15T03:30:59.278Z","last_seen_at":"2018-09-15T19:34:24.326Z","created_at":"2018-09-14T20:12:47.287Z","can_edit":true,"can_edit_username":true,"can_edit_email":true,"can_edit_name":true,"can_send_private_messages":true,"can_send_private_message_to_user":false,"trust_level":4,"moderator":true,"admin":true,"title":null,"uploaded_avatar_id":2,"badge_count":1,"has_title_badges":false,"custom_fields":{},"pending_count":0,"profile_view_count":4,"time_read":0,"recent_time_read":0,"primary_group_name":null,"primary_group_flair_url":null,"primary_group_flair_bg_color":null,"primary_group_flair_color":null,"staged":false,"second_factor_enabled":false,"second_factor_backup_enabled":false,"associated_accounts":[],"post_count":3,"can_be_deleted":false,"can_delete_all_posts":false,"locale":null,"muted_category_ids":[],"watched_tags":[],"watching_first_post_tags":[],"tracked_tags":[],"muted_tags":[],"tracked_category_ids":[],"watched_category_ids":[],"watched_first_post_category_ids":[],"system_avatar_upload_id":null,"system_avatar_template":"/letter_avatar_proxy/v2/letter/s/bcef8e/{size}.png","gravatar_avatar_upload_id":2,"gravatar_avatar_template":"/user_avatar/discourse.mydomain.org.uk/system/{size}/2_1.png","muted_usernames":[],"mailing_list_posts_per_day":0,"can_change_bio":true,"user_api_keys":null,"user_auth_tokens":[],"user_auth_token_logs":[],"invited_by":null,"groups":[],"group_users":[],"featured_user_badge_ids":[1],"user_option":{"user_id":-1,"email_always":false,"mailing_list_mode":false,"mailing_list_mode_frequency":1,"email_digests":true,"email_private_messages":false,"email_direct":false,"external_links_in_new_tab":false,"dynamic_favicon":false,"enable_quoting":true,"disable_jump_reply":false,"digest_after_minutes":10080,"automatically_unpin_topics":true,"auto_track_topics_after_msecs":240000,"notification_level_when_replying":2,"new_topic_duration_minutes":2880,"email_previous_replies":2,"email_in_reply_to":true,"like_notification_frequency":1,"include_tl0_in_digests":false,"theme_ids":[3],"theme_key_seq":0,"allow_private_m* Connection #0 to host discourse.mydomain.org.uk left intact
* Closing connection #0

I’ve installed a WP plugin called cURL Options as it promised to allow me to set some of the CURLOPT options, not that I completely understand what I’m doing, but in the process of Googling for curl error 7 issues, I saw that CURLOPT_FOLLOWLOCATION might need to be set to true to allow for redirects to a sub-domain. Anyway, cURL Options allows you to test the options by carrying out a cURL GET request from within WP, and this time I see a failure.

Despite the Success message, the body shows a 404 - The requested URL or resource could not be found message.

I think this is the most important clue I’ve found as it is Wordpress trying to do the curl connection and failing. I’ve double checked the URL and I’ve tried it with and without the overridden curl setting

The entire response from the test is shown below.

    [headers] => Requests_Utility_CaseInsensitiveDictionary Object
            [data:protected] => Array
                    [server] => nginx
                    [date] => Sat, 15 Sep 2018 19:54:15 GMT
                    [content-type] => text/plain; charset=utf-8
                    [x-request-id] => 1c957784-5910-4334-92a5-d295b7193cf3
                    [x-runtime] => 0.015182


    [body] => The requested URL or resource could not be found.
    [response] => Array
            [code] => 404
            [message] => Not Found

    [cookies] => Array

    [filename] => 
    [http_response] => WP_HTTP_Requests_Response Object
            [response:protected] => Requests_Response Object
                    [body] => The requested URL or resource could not be found.
                    [raw] => HTTP/1.1 404 Not Found
Server: nginx
Date: Sat, 15 Sep 2018 19:54:15 GMT
Content-Type: text/plain; charset=utf-8
Transfer-Encoding: chunked
Connection: close
X-Request-Id: 1c957784-5910-4334-92a5-d295b7193cf3
X-Runtime: 0.015182

The requested URL or resource could not be found.
                    [headers] => Requests_Response_Headers Object
                            [data:protected] => Array
                                    [server] => Array
                                            [0] => nginx

                                    [date] => Array
                                            [0] => Sat, 15 Sep 2018 19:54:15 GMT

                                    [content-type] => Array
                                            [0] => text/plain; charset=utf-8

                                    [x-request-id] => Array
                                            [0] => 1c957784-5910-4334-92a5-d295b7193cf3

                                    [x-runtime] => Array
                                            [0] => 0.015182



                    [status_code] => 404
                    [protocol_version] => 1.1
                    [success] => 
                    [redirects] => 0
                    [url] => https://discourse.mydomain.org.uk/users/system.json
                    [history] => Array

                    [cookies] => Requests_Cookie_Jar Object
                            [cookies:protected] => Array



            [filename:protected] => 
            [data] => 
            [headers] => 
            [status] => 


I have also tried placing specifc entries in /etc/hosts (both at the DO Droplet level and in the running container) as the problem looks like the connection makes it as far as the DigitalOcean droplet but, unlike the browser traffic, doesn’t get routed to the Docker container. I didn’t approach this very scientifically so won’t bother documenting the details here.

(Danny Goodall) #175

@Simon_Cossar, please hold off on the above request for help.

Right now, having just been about to shutdown for the night I tried one more time to save the options and I got connected to Discourse.

No other change, but it just worked.

I’ve spent a couple of days trying to get this to work so I can only assume that it might have been non-flushed cache or DNS propagating. My host made a change? SSL certificates working their way through the system?

Dunno, but it’s working - ATM.

Watch this space!

(Jay Pfaffman) #176

A dns problem was my guess. Maybe the wordpress side was caching old data.

(Jordan) #177

Hey @Simon_Cossar it looks like you’ve got a broken hyperlink: “here” :arrow_up: