WP Discourse plugin installation and setup

wordpress

#41

It’s look like webhook’s secret key problem. How can i found webhook’s secret key on Discourse? I can’t found it.


(Simon Cossar) #42

You need to set the secret key on Discourse. Look for this setting on on WordPress, found at Discourse/Webhooks.

Click on the URL in that setting to get to the Discourse webhook page. On Discourse, click the edit icon for the /wp-json/wp-discourse/v1/update-topic-content webhook. In the ‘Secret’ input, enter the secret key that you used on WordPress and save the updated webhook.


#43

Update topic content status 200, it works. But update user (/wp-json/wp-discourse/v1/update-user) status still 404. :frowning: And comments doesn’t seems yet.


(Simon Cossar) #44

Have you enabled the Update Userdata webhook? If so, could you test the route by going to your Discourse preferences page and try saving your preferences?

If comments are not updating, it could be because they are for posts that were published through an earlier version of WP Discourse.

Try enabling all these settings:


#45

I use lastest version of WP Discourse.

All these options enabled already.


(Simon Cossar) #46

On the Discourse webhook page, have you selected the Post event?


#47

Yes, I selected post event for wp-json/wp-discourse/v1/update-topic-content


(Simon Cossar) #48

Is your site on a multisite installation?

The way it is expected to work is that when a post is added to a Discourse topic that has been published through the wp-discourse plugin, the update-topic-content webhook tells wp-discourse to update the post’s comments the next time the post is requested. If you are testing this, you will need to refresh the page to get the updated content.

Depending on your settings on the wp-discourse Commenting tab, there may not be any change to the comments that are displayed. The Max Visible Comments setting will limit the number of comments that are displayed. Also the Min Number of Replies and Min Score of posts setting can have an effect.


#49

It works, but comments not updated instantly. After 24 hours later, seems one comment on blog post but topic has four comment. I use Cloudflare, could it be the reason?

Edit: Solved. It’s about WP Super Cache plugin.


(Simon Cossar) #50

That’s great to know. What did you do to fix the problem?


#51

I cleared cache on this plugin and problem solved for now. Maybe this plugin conflict with WP Discourse plugin, so probably I will disable it.


(Simon Cossar) #52

If the page is cached it won’t pull the updated comments from Discourse. I’d like to find a good way of dealing with this. Disabling the cache doesn’t seem like a great solution.


#53

You are absolutely right. It is not solution. :slight_smile: I will do some experiments with cache plugin in the following days. I hope we will find a solution.


(Bhanu Sharma) #54

Giving the comments box an exception to the list of cached resources or loading asynchronously can both be feasible.


#55

After stumbling upon the same issue like @bekircem (WP Super Cache), I get the comments in discourse pulled over to WordPress perfectly.

However, I cannot see any “Start the discussion at …” or “Continue the discussion at …” text with a link to discourse in my template (adapted Enfold). Using another template it works perfectly out of the box.

Do I have to adapt the functions.php of my template and which way? Cheers!


(Simon Cossar) #56

I’m going to add an option in the next update to load the comments with an ajax call. That should take care of any issues with cached pages.

I’m not sure what is going on with the Enfold theme. If I could take a look at the theme’s code I could probably sort it out.


#57

Thanks for your immediate reply, Simon.

To be honest: I don’t think it is necessary to change the behaviour concerning the caching mechanism. As long as one knows how caching is working, he ought to get used to it: there are other places as well like when changing the template files etc. However, it just could unsettle newbies a bit :wink:

Unfortunately I am afraid, I can’t give you the code of the Enfold theme as I am not sure about its license.
What I did: Switched the theme from child to parent in my local installation (without caching enabled) and saw the same issue. Hence, apparently we didn’t do something wrong with the child theme - certainly seems to be an issue with the Enfold theme.

On Monday or within the next few days, I will try to consult one of our professional developers (different to me ^^) about it. I’m sure these good guys will find a proper solution that I should be able to post here. I’ll also inform the Enfold team about this issue.

Cheers, have a good weekend!


(Simon Cossar) #58

The only other theme I’ve seen this with it the Timber theme. The issue there is that it uses a twig template to load the WordPress comments, instead of the normal WordPress comments template. There is a workaround for that.

If your developers have any questions, send them this way. If they find a solution, please post it.


(Frank Bailey) #59

Can anyone suggest a way to troubleshoot publishing to Discourse not working?

Any post I try to publish displays the error “There has been an error publishing this post to Discourse.”. In the settings the “You are connected to Discourse!” is displayed, so I’d think it should work, but the posts definitely don’t appear in my Discourse.

I’ve tried turning on WP_DEBUG_LOG in the wp-config file, but the log file doesn’t appear when I try to publish a post.

I should mention that my WordPress installation is on my Windows 10 host and the Discourse installation is a Docker container in an Ubuntu 16.04 VirtualBox guest, if that might have something to do with it.


(Simon Cossar) #60

I’m assuming you are working in a development environment.

You need to create a debug.log file in the wp-content folder. You may need to change that file’s permissions so that the webserver can write to it. Set WP_DEBUG and WP_DEBUG_LOG to true.

A good function for debugging is:

function write_log( ...$log_items ) {
	if ( true === WP_DEBUG ) {
		foreach ( $log_items as $log_item ) {
			if ( is_array( $log_item ) || is_object( $log_item ) ) {
				error_log( print_r( $log_item, true ) );
			} else {
				error_log( $log_item );
			}
		}
	}
}

Yes, that might be the problem. If you can get the seteup I outlined above to work, find the statement $result = wp_remote_post( $url, $post_options ); in discourse-publish.php wp-discourse/discourse-publish.php at master · discourse/wp-discourse · GitHub

Below it, add a line like this to see what is being returned from Discourse. To rule out another possible error, try this with a post that you haven’t previously attempted to publish to Discourse.

write_log( 'Discourse publishing response', $result );