Wp-discourse dysfunctional, shows only "Start the discussion at ..."


(Adrelanos) #1

wp-discourse settings…

Discourse URL is set to:

API Key is copied/pasted from https://forums.whonix.org/admin/api.

I’ve checked “Publish all new posts to Discourse”.


discourse version:
v1.5.0.beta5 +9

wordpress version:
4.3.1

wp-discourse version:
0.6.6


Issues:

Any idea what could be wrong?


WP-Discourse > 'Publish all new posts to Discourse.' > not working
(Steven Greco) #2

Try regenerating the api key. or make sure when you copied/pasted you did not grab any spaces.

If you are not getting a category drop down it means its not connecting to the Discourse site.


(Adrelanos) #3

I’ve revoked and regenerated the API key a few times. Made sure no spaces were copied. Either way. Category drop down always dysfunctional.


(Steven Greco) #4

Does not look like the plugin is loading correctly. Your “start the discussion” link is also not populating. Is there anything in your php logs? You can try removing and re-installing the plugin to see if that works, if you haven’t already.


Cannot Post to Discourse instance, Published Category does not Display in settings
(Adrelanos) #5

I’ve deleted and reinstalled the plugin. Didn’t help.

Php logs? Apache error log will do? See this please.

[Wed Nov 25 18:32:43.553980 2015] [:error] [pid 28349] [client 127.0.0.1:41505] PHP Warning:  First parameter must either be an object or the name of an existing class in /var/www/blog/wp-content/plugins/wp-discourse/lib/discourse.php on line 507
[Wed Nov 25 18:32:43.554671 2015] [:error] [pid 28349] [client 127.0.0.1:41505] A valid URL was not provided.
[Wed Nov 25 18:32:45.179254 2015] [:error] [pid 3329] [client 127.0.0.1:41623] PHP Warning:  First parameter must either be an object or the name of an existing class in /var/www/blog/wp-content/plugins/wp-discourse/lib/discourse.php on line 507, referer: https://www.whonix.org/blog/
[Wed Nov 25 18:32:45.179916 2015] [:error] [pid 3329] [client 127.0.0.1:41623] A valid URL was not provided., referer: https://www.whonix.org/blog/
[Wed Nov 25 18:32:45.274992 2015] [:error] [pid 3329] [client 127.0.0.1:41623] PHP Warning:  First parameter must either be an object or the name of an existing class in /var/www/blog/wp-content/plugins/wp-discourse/lib/discourse.php on line 507, referer: https://www.whonix.org/blog/
[Wed Nov 25 18:32:45.275563 2015] [:error] [pid 3329] [client 127.0.0.1:41623] A valid URL was not provided., referer: https://www.whonix.org/blog/

I’ve tried various notations of the Discourse URL.

None is working.


(Steven Greco) #6

What do you have for your Discourse settings?


(Adrelanos) #7

At the moment Discourse URL is set to https://forums.whonix.org/.

Not sure I understand. Would you like to see all options from Log In ‹ Whonix — WordPress?


(Adrelanos) #8

Discourse URL | https://forums.whonix.org
API Key | copied and pasted from https://forums.whonix.org/admin/api
Publishing username | left empty (also tested to fill out with WhonixBlog)
Published category | a non-clickable drop down menu
Publish format | <small>Originally published at: {blogurl}</small><br>{excerpt}
Use full post content | not [yet] enabled
Auto Publish | enabled
Auto Track Published Topics | enabled
Post Types to publish to Discourse | default (post page
Use Discourse Comments ¦ enabled
Show Existing WP Comments | enabled
Existing Comments Heading | empty
Max visible comments | default 5
Min number of replies | default 5
Min score of posts | default 30
Min trust level | default 1
Bypass trust level score | default 50
Custom excerpt length | default 55
Custom Datetime Format | default, empty
Only import comments liked by a moderator | default, disabled
HTML Template to use when there are replies | default
HTML Template to use when there are no replies | default
HTML Template to use for each comment | default
HTML Template to use for each participant | default
Debug mode | disabled
Enable SSO | disabled
SSO Secret Key | empty


(Stephen) #9

Does the account referenced in publishing username exist on your Discourse? If it’s not a valid user it won’t work. Looking at your forums it doesn’t appear that ‘WhonixBlog’ is a valid user.

If you don’t specify an account then the user who posts to WordPress must have a valid discourse username specified on their Wordpress account. Does ‘adrelanos’ have their Discourse name specified on their profile?

It’s unlikely that the publishing username is preventing you from seeing the categories, but it will block you from posting to your Discourse instance. We’ve had several incidents where users have changed their usernames at either WP or Discourse and thread creation stops dead in its tracks.


(Adrelanos) #10

Publishing username was empty before. Didn’t work.

No, the user name WhonixBlog didn’t exist. Failed with that setting also. I assumed it would be created by wp-discouse. Sorry.

Publishing username still empty for now, and I would like to let it that way, if that is okay.

Setting my wordpress user profile setting Discourse Username to Patrick, which is my discourse user account helped. Thanks for that tip! Clicking on Start the discussion at forums.whonix.org now redirects to the forum discourse integration test - Whonix Forum where the blog post is now mirrored. Yay!

There still is an issue. In wp-discourse settings, I still cannot choose a category. (Reloaded the settings page several times.) Any idea?

There is now one message in the log when I reload the wp-discourse settings page.

[Thu Nov 26 01:19:43.872584 2015] [:error] [pid 3329] [client 127.0.0.1:35790] PHP Warning: Invalid argument supplied for foreach() in /var/www/blog/wp-content/plugins/wp-discourse/lib/admin.php on line 257, referer: https://www.whonix.org/blog/wp-admin/options-general.php?page=discourse

Is that related?


(Stephen) #11

If the publishing username for the plugin is empty, you have to populate the per-user setting. Pick one.

The plugin creates the posts as a user, if the user doesn’t exist the plugin can’t create the posts on Discourse, it’s that simple. I would advise creating a forum account that will post whenever the WP user doesn’t exist, otherwise when someone else posts on your blog the stub thread can’t be created.


(Adrelanos) #12

Okay. Understood.


Any way to debug the unclickable Published category further?


(Stephen) #13

Well @benword can probably clarify, but the plugin may be using the specified username to enumerate permissions and identify categories for which it has publishing rights. I would recommend putting ‘patrick’ in there too as a test for now. You can always remove it later.

That would explain why this loop:

foreach( $categories as $category ){
      printf( '<option value="%s"%s>%s</option>',
        $category['id'],
        selected( $selected, $category['id'], false ),
        $category['name']
      );

Returns nothing. Looking at the plugin code it sends both the username and the API key.


(Adrelanos) #14

Okay,I’ve put patrick (or test wise also Patrick) into Publishing username. Save changes. Reload page. The Published category is still unclickable.


(Adrelanos) #15

Today, one day later, without having any changes made, I could choose a Published category. Strange.

Posted a new test blog post:

There are no more errors in apache log.

However, replies in discourse are not synced back to wordpress. Any idea why that is?


(Adrelanos) #16

Published category became unclickable again. Very strange.


(Adrelanos) #17

@AdamCapriola fixed it for me as part of a commercial service. He is okay with me posting his solution here.


Here are the settings that needed to be adjusted:

Before

Screen Shot 2015-12-02 at 7.16.11 PM.png1662x166 18.7 KB

Screen Shot 2015-12-02 at 7.00.47 PM.png2116x788 77.6 KB

After

Screen Shot 2015-12-02 at 7.16.24 PM.png1666x154 20.1 KB

Screen Shot 2015-12-02 at 7.17.40 PM.png2102x790 77.2 KB

We needed something for the publishing username (any registered Discourse user). It's best for it to be an admin, otherwise if you publish to a private category then the plugin won't be able to poll for replies. system is my go-to default.

The min number of replies, min score of posts, and min trust level also needed to be calibrated. I set them to the bare minimum (i.e. all posts will be pulled over); you might want to set different requirements.

Once you visit a post in WordPress, it will sync the comments over (but not once more than every 10 minutes, unless you check the "debug mode" option in the plugin). The comments template can be adjusted on the plugin settings page.