Configure WP Discourse Webhooks

You can use webhooks to sync data between Discourse and WordPress, and enrich your integration. Reply to this topic if you have questions about how to setup the webhooks, or how they work.

Setup

WP Discourse

First setup an endpoint in WP Discourse:

  1. Navigate to WP Discourse > Webhooks in Wordpress admin.
  2. Select the endpoint(s) you want to enable (see below).
  3. Set a “Webhook Secret Key”, if it’s not already set.
  4. Click “Save Options”.

Discourse

Then create a new Webhook in Discourse (Go to /admin/api/web_hooks/new):

  1. Copy the Payload URL from the relevant setting in WP Discourse.
  2. Enter the Secret you set in “Webhook Secret Key” in WP Discourse.
  3. Select the Events from the relevant setting in WP Discourse.
  4. Select “Active”.
  5. Click “Create”.
  6. Send a “Ping” to ensure the webhook is working.

Endpoints

Sync Comment Data

This endpoint keeps Discourse post data stored in Wordpress up-to-date as posts are updated on Discourse. This means that when Discourse comments are loaded on a Wordpress post up-to-date comment data is available without needing to make a request to Discourse. This may improve the performance of Wordpress posts that have Discourse comments.

Settings

Match Old Topics. When enabled, the Sync Comment Data endpoint will try to match Discourse topic titles to Wordpress post titles if the endpoint hasn’t been able to find any other relevant data to match from a Webhook payload. Keep this disabled unless you have a specific reason to enable it.

Update Userdata

This endpoint keeps Discourse user data stored in Wordpress up-to-date as it changes in Discourse. This will automatically set and update the “Discourse Username” in the Wordpress user profile, which is used to set the user when publishing posts to Discourse.

Requirements

WP Discourse must be functioning as the DiscourseConnect Provider for Discourse to use this webhook.

Settings

Match Users by Email: When enabled, the Update Userdata endpoint will try to match Discourse users to Wordpress users by email if the endpoint hasn’t been able to find any other relevant data to match from the Webhook payload. Keep this disabled unless you have a specific reason to enable it.

5 Likes