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.”
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.
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.
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”.
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.
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)!
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.
We basically have 3 blogs on a multisite set up that post to the same Discourse forum. 2 of the 3 work fine with no issues, but one of them now returns a similar “Forbidden” error that @pgross mentioned earlier. I’ve tried the suggestions here with no luck. All the posts are posted by the same user and it worked fine for the last few months up until yesterday, so I’m a bit stumped here.
Can you find any difference between what is happening on the site that you are getting the Forbidden error on and the other sites? For example, are you publishing to a protected category on the site that is failing? Are you adding tags to topics that you are publishing to Discourse. If so, is there a chance that the tags are not allowed in the category that you are publishing to?
Do you have the WP Discourse “Add Featured Links” option enabled? That option is found on the Publishing settings tab.
Hey @simon, all 3 blogs are essentially the same blog but in a different language. They’re all set up exactly the same, so as far as I can see, there are no differences. We haven’t been adding any tags. We do use the “Add Featured Links” option.
Hope that helps?
Edit: Just wanted to add, did a test with a new post, and it works fine, but the particular post that did not get pushed is still Forbidden.