发布主题时出错: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 个赞

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 个赞

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

我们基本上在一个多站点设置中拥有 3 个博客,它们都发布到同一个 Discourse 论坛。其中 2 个博客运行正常,没有任何问题,但其中一个现在返回了与 @pgross 之前提到的类似的“禁止访问”错误。我尝试了这里的建议,但毫无成效。所有帖子都由同一用户发布,并且直到昨天为止一直运行正常,所以这让我有些困惑。

您能否找出在出现“禁止访问”错误的网站与其他正常网站之间有什么不同?例如,您是否正在向受保护的分类发布内容?您是否在向 Discourse 发布主题时添加了标签?如果是,这些标签是否可能不被允许发布到该分类中?

您是否启用了 WP Discourse 的“添加精选链接”选项?该选项位于“发布设置”标签页中。

1 个赞

@simon,这三篇博客本质上都是同一篇博客,只是语言不同。它们的设置完全一样,据我所知没有任何区别。我们一直没有添加任何标签,但确实使用了“添加精选链接”选项。

希望这能帮到你?

编辑:想补充一下,我用新文章做了测试,一切正常,但那个未能推送的特定文章仍然显示“禁止访问”。

1 个赞

您能否尝试安装 Query Monitor – WordPress plugin | WordPress.org English (Canada) 或类似的插件,然后再次尝试发布该帖子?它应该会提供一条详细的错误信息,说明从 Discourse 收到的响应。

编辑:您是向 Discourse 发布完整的帖子内容,还是仅发布帖子的摘要?

1 个赞