Error publishing topic with WP Discourse

Hi Simon,

I have a site (mycp.org) that has Wordpress as the master SSO. Everything is working well except for publishing to discourse. I had selected autopublish but I saw that this didn’t work with the block editor. I tried checking force publish and then updated the post. No joy. So I installed the classic editor (I’m not enamored with Gutenberg and all of its extra goo.) Tried to publish. No joy. Turned off force and auto and tried to publish an update from the editor (though I didn’t change anything this time). All along I’m getting this error: “There has been an error publishing your post. Please try again.”

Any thoughts on how to correct it or debug it?

Thanks,

paul

Are you getting the error with all posts, or just with a specific post?

If the problem is only happening for a specific post, go to the post’s edit screen and select ‘Custom Fields’ from the Screen Options tab that should be near the upper right of the page:

Once you’ve done that, scroll down to and expand the Custom Fields meta box. If you see any fields that match the ones in this screenshot, you can safely click the ‘Delete’ button for them and try publishing the post to Discourse again. If you see a wpdc_topic_tags field, you can also delete that. It is possible that field is causing the issue (Discourse now returns an error for unallowed tags) - I’m implementing a fix for that right now.

Let me know if this works, or if you’re still getting errors.

Hey Simon,

It has been a while since I have tried with other posts so I can answer that first question. I did follow these instructions. There was one more field not show here, wpdc_publishing_error, which before and after this attempt (it didn’t work) has the value “Forbidden”.

I can try another post and update it if that would help.

Paul

That helps! Can you check the values that you’ve entered on the plugin’s Connection Settings tab? Make sure you are using your Discourse site’s All Users API Key and that the Publishing Username is set to ‘system’. The only case where this shouldn’t be set to ‘system’ is if you have edited the username of the System user on Discourse.

Next, go to your WordPress profile page and check that your Discourse Username exactly matches your username on Discourse. The Discourse Username field is found near the bottom of your WordPress profile page.

My name on Wordpress is Paul_Gross. My Discourse username is Paul_Gross. I don’t see a user named “system” when I go to the Users page on Discourse and search for “system”.

The site user contact name is “system”.

If you go to your Admin / Users / Staff page, you should see a user with the name ‘system’ in the list. If you don’t see that user, it is possible that it was either deleted or renamed.

It’s there. But right now I’m getting a “You are not connected to Discourse” on the WP Discourse Connection page. Not sure why…

Fixed that and still getting Forbidden…

Does the user you are trying to publish the post under have the rights to publish topics in the Discourse category you are publishing the post to? The user who the post is published by is set by the Discourse Username you have set on your profile page.

Could you try publishing a fresh post to your site to see if the issue has something to do with this specific post?

I would think the user, me, Paul_Gross, admin and creator of the post on Wordpress has rights to publish under the category on Discourse that I defined (Research). I am the admin on both sides of this equation. Other reasons for being “forbidden”?

BTW, thanks for your rapid fire dive on this. I have to leave my computer now so I will be able to answer from my phone but real digging requires me to have a big screen and a keyboard (my limitation – not Discourse responsive)!

Paul

1 Like

It’s no problem. I’m working on a feature right now that will improve the error messages that get returned from Discourse. “Forbidden” on its own isn’t very helpful. When you get a chance, try publishing a fresh topic and let me know how that goes.

1 Like

Great. W’ill do and will post back…

Hi Simon,

I’m not sure if this counts but I copied the content into a new post and posted it. Still got the Forbidden error code in the custom fields…

Paul

9 posts were split to a new topic: WP Discourse 1.9.5 bug