WP Discourse と Discourse フォーラムの連携に問題が発生

Hello,

I’m working on a wordpress site and have the WP Discourse plugin installed. Our objective is obviously to sync our wordpress site with the Discourse forum so that when a post is published to the site it is also published to Discourse.

However until now it didn’t work much. While creating a post, even with the “Create new Topic” Discourse box checked, it does not work and the post isn’t created in the forum.

I went to the WP Discourse plugin settings and to me everything seemed to be fine (everything isn’t obviously fine and I may have done something wrong as it doesn’t work), the Discourse API key is correct as well as the SSO secret key, as I’m also trying to use my wordpress site as an SSO provider.

I noticed in the WP Discourse plugin settings that there were two error messages, when accessing the “SSO Provider” and “Connection” tabs:


which is quite problematic because there IS an admin user with this email address on the forum (myself).
and most importantly, “You are not connected to Discourse. If you are setting up the plugin, this notice should go away after completing the form on this page.”

Soooo my wordpress and Discourse don’t seem to be synced. Can I please get some help in order to solve this ? Feel free to ask if you need more information - I guess you obviously do

The first thing to sort out is the issue on the Connections tab. The plugin won’t work until you establish a connection with Discourse.

What have you set for the Publishing Username on that tab? It should be set to either the Discourse username of the system user (‘system’ by default) or the username of an admin user from your forum.

What version of WordPress are you using?

「いいね!」 3

Hello Simon, thanks for the answer.

So it seems really dumb, but as expected the Publishing Username wasn’t correct (I missed a space on the name). I fixed this and now I have the “You are connected to Discourse!” message.

Also no more error message on the SSO Provider tab. By the way I’m using WordPress 4.9.3.

Anyway, sorry for the inconvenience and thanks again for the answer. I’ll update this thread/create another one if I have any other issue especially with synchronizing the creation of posts between Wordpress and the forum.

「いいね!」 3

Hi,

Although I put all the needed info to Connection tab but it still shows

You are not connected to Discourse. If you are setting up the plugin, this notice should go away after completing the form on this page.

Please help.

Discourse: https://forum.biohack.vn
WP: https://biohack.vn
I use admin as the username since it’s the Discourse admin.

Try using ‘system’ for the username.

「いいね!」 1

Already before I switch to admin.

For the Publishing Username setting, you need to use the username of your Discourse System user. That username defaults to ‘system’ (without the quotes.) For the API Key, use the All Users API Key. You can find that key at /admin/api/keys.

When I try to visit your site at http://biohackplus.com/, the page isn’t loading for me. Are you able to access it at that URL?

Let’s not open more than one topic on the same exact thing please.

「いいね!」 2

I was able to connect to Discourse. However, although I put all the needed info Publishing tab, when I create a post in Wordpress, it doesn’t show in Discourse.

What I’m trying to do: When I create a post in a category in Wordpress, the plugin will create a post in Discourse with link to my Wordpress post in a matched Discourse Category.

This topic has instructions for publishing posts to Discourse: WP Discourse now supports the WordPress Block Editor. Is this working for you?

「いいね!」 1

私のサイトでも同様の問題が発生しています。WP Discourse をインストールし、全ユーザー用の API キーを作成しましたが、公開ユーザー名は「system」のままです。それでも「Discourse に接続されていません…」というメッセージが表示されます。私のサイトは Cloudflare でプロキシされていますが、現時点では正常に動作しているようです。ご助力いただければ幸いです。Discourse のバージョンは 2.6.0.b4 です。

こんにちは @sturdy2 さん、その問題が発生する理由はいくつか考えられます。以下の設定を試してみてください。

Discourse: 管理者ユーザーのグローバル API キーを作成

設定は以下のようになります。

WordPress: そのキーを使用し、「公開ユーザー名」を選択した管理者ユーザーに設定

(「Discourse URL」フィールドには、スクリーンショットに表示されているものではなく、ご自身の Discourse の URL を入力してください)

「いいね!」 1

こんにちは、@angus さん、ご返信ありがとうございます。残念ながら、ご指示通り単一ユーザーキーを作成しましたが、依然として「接続なし」のメッセージが表示されます。考えられることはすべて試しましたが、解決しませんでした…再度ありがとうございます。

わかりました、解決策を探してみましょう。

確認ですが、「グローバルキー」(すべての操作を許可)を作成されましたか?

作成されたと仮定して、以下の点を確認してください。

  1. Discourse と WordPress はそれぞれどこでホストされていますか?

  2. Discourse にカスタムプラグインはインストールされていますか?

  3. WordPress にこの ヘルスチェックプラグイン をインストールしてください。

    • このプラグインで重大な問題が検出されましたか?

    • トラブルシューティングモードを有効にし、wp-discourse プラグインのみを有効にしてください(他のすべてのプラグインは無効になります)。その後、再度接続を試みてください。

「いいね!」 1

はい、Global で、単一のユーザー(私自身、管理者)です。WP Discourse が接続しません。

  1. Discourse は DO によってホストされています
  2. カスタムプラグインについてはわかりません。
    3a. Health Check & Troubleshooting(別名 Site Check)はしばらく前にインストール済みです。Yoast SEO が報告した「疑問のある」重大な問題の一つは「検索エンジンがあなたのサイトを検出できません」というものです。さらに詳しいトラブルシューティングの手順では、「Google がモバイルフレンドリーテストを実行できる場合、Google はドメインもクロールできます。その場合、Ryte の警告は誤りです」と記載されています。ドメインとサブドメインの両方でテストを通過しています。
    3b. 以前も今回も試しました。WP Discourse を除くすべてのプラグインを無効にしましたが、WP Discourse は接続しません。

更新:数日間これと格闘していますが、理解できないことがいくつかあります。おそらく、これらほとんどが私にとって全く新しいことだからでしょう。

  1. Discourse サブドメインの DNS「A」レコードは、DO によって割り当てられた IP(SSH に使用しているのと同じ IP)を指していますが、dig discourse.example.com は Cloudflare によって割り当てられたと思われる 3 つの異なる IP を指し、dig https://discourse.example.com は別の IP whois BAREFRUIT-ERRORHANDLING(GB 所在)を指しています。何かおかしいはずです!

  2. WP Discourse は Discourse と接続するために cURL を使用すると想定して、cURL と Discourse API で実験を続けています。3 つの API キー(上記で確認済みのキーを含む)を持っています。昨日まで、3 つすべてが「未使用」と表示されていました。昨日、昨年 8 月に作成した元のキーが「1 日前に使用」と表示されていることに気づきました。残りの 2 つは依然として「未使用」です。これは、おそらく cURL の実験のいずれかが実際に接続したことを意味していると思われます。残念ながら、どの実験が実際に機能したかはわかりません。また、HTTP 200 を返す cURL コマンドは API の「最終使用」情報を変更しない(「未使用」のまま)ことも確認しました。

上記の #1#2 はどちらも重要だと思われますが、まだ問題の特定ができていません。

お待たせして申し訳ありません。生活に追われることもありますので。改めて、@angus さん、ご協力ありがとうございます。

はい、設定から Cloudflare を除外してみてください。エラーの可能性がある原因を特定する必要があります。

「いいね!」 1

@angus さん、こんにちは。

追伸:Query Monitor プラグインを WP にインストールしました(出力は以下参照)。

ローカル PC で cURL を使用しても 403 エラーが発生するため、これは私のサイトと WP Discourse の間のアップストリーム側の問題(おそらく Cloudflare)だと考えています。ただし、まだ Cloudflare を削除したくはありません。詳細は以下をご覧ください。

私の遅延について改めてお詫び申し上げます。ホスティングサービスから、サイトが別のサーバーに移行され、IP アドレスの変更を含むいくつかの変更が行われるという通知を受け取りました。そのため、この問題に関するさらなる作業を一時的に延期する必要があります。落ち着きを取り戻した後に、再びお手伝いをお願いしてもよろしいでしょうか?

編集:解決しました!おそらく /admin/site_settings/category/securityallowed crawler user agents のバグです。
「許可 UA」テキストに何らかのエントリがあると、ローカル PC からの curl コマンドラインであっても、すべてのリクエストがブロックされてしまうようです。このテキストを空に戻すと、即座に WP Discourse で「Discourse に接続されています!」というメッセージが表示されます。

「いいね!」 3

解決できてよかったです!:tada:

はい、その設定は非常に制限が厳しいことを意図していると思います(そのため、説明書には大文字で警告が記載されています)。

allowed crawler user agents を使用しながら WordPress インスタンスを許可するには、以下のように追加してください。

Wordpress/<wordpress_version>

私は自分のテスト環境(WordPress / Discourse)で allowed crawler user agentsWordpress/5.5.3 を追加して試しましたが、問題なく動作しました :+1:

WordPress をアップグレードするたびにこの設定を更新したくない場合は、WordPress 側でこれらのリクエストに対して独自のユーザーエージェントを設定するシンプルなプラグインを使用できます。例えば以下が挙げられます。

https://github.com/webdeveric/wp-user-agent

「いいね!」 2

ご説明いただきありがとうございます。ようやく理解できてきました。当初、「許可されたクローラーユーザーエージェント」は許可された検索エンジンクローラーを特定するためのものだと誤解していました。WordPress のユーザーエージェントを使用している WP Discourse が許可されないと判断されることを知らずに、最初は「Googlebot」と入力してしまいました。これもまた初心者の間違いですね。このような誤解はよくあることだと思いますが、限られたドキュメントやさらに限られた例の中では何も見つけることができませんでした。

「許可されたクローラーユーザーエージェント」として、現在は「Wordpress」(バージョンは不要)、Googlebot、そして以下に示す cURL での使用のために追加した「Discourse」を使用しています。何か問題がありますか?それとも他を追加する必要がありますか?

cURL を使用して Discourse API にアクセスする場合も同様の問題がありました。以前はユーザーエージェントを以下のように追加するまで 403 エラーが発生していました。

Discourse API ドキュメントに掲載された最初の例(私の環境では動作しません):
curl -X GET "http://127.0.0.1:3000/admin/users/list/active.json" \
-H "Api-Key: 714552c6148e1617aeab526d0606184b94a80ec048fc09894ff1a72b740c5f19" \
-H "Api-Username: system"
ユーザーエージェントオプションを追加した後に動作する例:
curl -A Discourse -X GET "http://discourse.example/admin/users/list/active.json" \
-H "Api-Key: 714552c6148e1617aeab526d0606184b94a80ec048fc09894ff1a72b740c5f19" \
-H "Api-Username: system"

個人的な意見ですが、完全に動作する例でなければ公開すべきではないと思います…ああ。

@angus さん、お手伝いとサポートをいただき本当にありがとうございます。

「いいね!」 1

こんにちは、

WordPress と Discourse の両方と連携する会員管理プラグインとして私が知っているのは Memberful だけです。Discourse との統合方法に関する詳細な手順もこちらに載っています – Integrate Discourse with Memberful - Memberful

すでに他の会員管理プラグインを使用されている場合は、直接その開発者に問い合わせることをお勧めします。私はこれをクライアントのウェブサイトのポートフォリオで利用したことがあります – https://www.fiverr.com/iamadil2/build-responsive-wordpress-website-design-wordpress-blog

「いいね!」 2