🎉 Celebrate with 10% OFF on All Products! Use Code: GFEX10 Or Buy Any 2+ Items for 30% OFF with Code: GFEX30!

Gravity Forms Discourse Premium Add-on Setup Guide

Updated 9 min read Gravity Forms Integrations A–Z
On this page
  1. Video walkthrough
  2. What you need
  3. Step 1: create the API key in Discourse
  4. Step 2: connect the forum
  5. Step 3: build the form
  6. Step 4: add a Discourse feed
  7. Create a topic
  8. Reply to a topic
  9. Send a private message
  10. Options
  11. Who posts: the API user or the forum member
  12. What you see after a submission
  13. When the forum is busy or down
  14. Conditions and several feeds
  15. Security and privacy
  16. For developers
  17. Frequently asked questions
  18. Does it work with a hosted Discourse forum?
  19. Can visitors without a forum account post?
  20. Can it reply to a topic that was made by an earlier submission?
  21. Are uploaded files sent to the forum?
  22. What happens if my license expires?

Video walkthrough

Gravity Forms Discourse Add-On Setup Guide: API Key, Feed & Merge Tags (WordPress Side)
Video setup guide: Gravity Forms Discourse Watch on YouTube

The Gravity Forms Discourse Premium Add-on sends a Gravity Forms submission to your own Discourse forum. Depending on the feed, it creates a topic, posts a reply to a topic, or sends a private message. It can also look after the forum member: it finds the member who has the e-mail address from the form, or creates the member, and posts as that person. This guide shows how to connect the forum, build a feed and test it.

The add-on talks to the Discourse REST API (the interface described in the official Discourse API documentation) with an API key and an API user name. Nothing goes through GravityExtra: the requests go from your WordPress site straight to your forum.

What you need

  • WordPress 6.5 or newer and PHP 7.4 or newer.
  • Gravity Forms 2.9 or newer. The add-on is tested with Gravity Forms 3.1.2 on PHP 8.3 and Gravity Forms 2.9.8 on PHP 7.4.
  • A Discourse forum that you manage, reachable from your web server with https, and an administrator who can create an API key.
  • An active license key for this add-on.

If Gravity Forms is missing or older than 2.9, the add-on shows a notice in the WordPress admin and does nothing else.

Step 1: create the API key in Discourse

  1. Sign in to your forum as an administrator and open Admin → API → Keys.
  2. Press New API Key and give it a description such as Gravity Forms.
  3. For User Level, choose All Users if the add-on should post as the people who fill in your forms (user sync) or as a user other than the one you name. Choose Single User if every post may come from one account.
  4. Press Save and copy the key. Discourse shows it only once.

The key needs a scope (the part of the API it may use). A global key works with every feature in this guide. If you prefer a limited key, allow at least the topics and posts actions, and for user sync also allow reading and creating users and managing group members. A limited key that lacks a permission gives a clear error in the entry notes, never a silent failure.

Step 2: connect the forum

Open Forms → Settings → Discourse. Activate your license key first, then fill in the forum section.

  • Forum address: the address people use to open the forum, with https, for example https://forum.yoursite.org. A forum in a folder (https://yoursite.org/community) is fine. Addresses with a user name, a query or a fragment are refused.
  • API user name: the user the key acts as. The default is system. Posts made without user sync are made by this user.
  • API key: paste the key. The field is a password field and is always empty when you come back. The key is encrypted before it is written to the database, and the screen shows only the last four characters.
The Discourse settings screen: forum address, API user name, a password field for the API key and the Test the connection button with a green result
Forms, Settings, Discourse: the address of your forum, the API user and the key. The key is saved encrypted.

Press Save Settings, then Test the connection. A green message such as Connected. The key can read 3 categories. means the address, the key and the user name work. If the test fails, the message shows what the forum answered, for example that the key was not accepted.

To change the key later, paste the new one and save. To keep the old key, leave the field empty.

Step 3: build the form

Use any Gravity Forms form. For a topic you need at least a title and a text. A drop-down with the categories, a field for tags and a name and e-mail address (for user sync) are optional.

A Gravity Forms form with a title, a question, a category and tag fields that creates a Discourse topic when it is sent
A plain form. The visitor never sees Discourse; the feed does the posting.

Step 4: add a Discourse feed

Open the form, then Settings → Discourse, and press Add New. Give the feed a name and choose what it should do.

The Discourse feed settings: name, action, title with merge tags, category, tags, the text of the post, who posts and the user sync fields
A feed: what to post, where, and as whom. Merge tags work in the title, the tags and the text.

Create a topic

  • Title: text with merge tags, for example the Title field of the form. Discourse has its own limits for titles (by default a minimum of 15 characters), and a title that is too short is shown in the entry notes with the forum message. The add-on cuts a title that is longer than 255 characters.
  • Category: choose from the list that the add-on reads from your forum. Sub categories are shown as Parent / Child.
  • Category from a form field (optional): choose a field whose value is the category number, its slug or its name. If the value does not match a category, the category above is used.
  • Tags: separated by commas, merge tags work. The add-on makes them lower case and without spaces, and sends at most ten.
  • Text of the post: Markdown with merge tags. If you leave it empty the add-on posts every answered field as a bold label and its value, and leaves out fields hidden by conditional logic, password, CAPTCHA and payment card fields.

Reply to a topic

Choose Reply to a topic and give the topic number: the number at the end of a topic address, such as 123 in /t/my-topic/123. It can come from a form field with a merge tag, so one form can answer different topics. Add a post number if the reply should answer one particular post. A number that is not a plain positive number is refused before anything is sent.

Send a private message

Choose Send a private message, then list the recipients: forum user names or group names, separated by commas. Use it to tell your support team about a new request without making a public topic.

Options

  • Stop @mentions in the post (on by default): a visitor can type anything into a form, including @all or the name of a moderator. With this option the add-on breaks every @mention in the text, so nobody is notified by a submission. Switch it off only when you write the mentions yourself in the template.
  • Give the post the date of the entry: the post gets the time of the form submission instead of the time it reached the forum. This matters after a retry.
  • Try again later (on by default): see below.

Who posts: the API user or the forum member

By default the post is made by the API user. With user sync the post is made by a forum member who matches the person who filled in the form.

  • The API user: simplest. Add the name of the person to the text if you want it shown.
  • The forum member with the e-mail address of the form; create the member if there is none: the add-on looks the e-mail address up on the forum. If a member has it, the post is made as that member. If not, the add-on creates a member with the name from the form and a user name made from the name (or the user name field, if you choose one). A name that is taken gets a number added. The new member is active and approved and gets a random password, so the person signs in with the forum login link or the forgot password link.
  • The forum member with the e-mail address of the form; do not post if there is none: for forms where only existing members may post. No member means no post, and a note says why.

You can also add the member to groups: enter the group numbers separated by commas. A group that cannot be changed (the key may not manage it) shows a note, and the post is still made.

Looking members up by e-mail address needs a key for all users with administrator rights, because Discourse hides e-mail addresses from everyone else. If the key is not allowed to do it, the note says so.

What you see after a submission

Every step writes an entry note, and the new topic is linked from a Discourse box on the entry screen.

  • A success note: what was created, who posted and the address of the post.
  • Entry meta values for the topic number, the post number, the address and the forum user, which you can use in notifications and confirmations.
  • The merge tags {discourse:topic_url}, {discourse:topic_id}, {discourse:post_id} and {discourse:username}. Use them in a confirmation, for example to send the visitor straight to their topic.
  • If something failed, a note with the message from the forum, and a Send to the forum now button in the entry box.

When the forum is busy or down

A visitor is never kept waiting for the forum and never sees a forum error: the form is saved and confirmed first. If the forum answers with a temporary error (a 5xx status, a timeout or a rate limit), the add-on schedules another attempt with WordPress cron: after 1 minute, 5 minutes, 30 minutes and 2 hours. When the forum says how many seconds to wait, the add-on waits at least that long. After the fifth attempt it stops and leaves a note.

Errors that cannot be solved by waiting are not retried: a wrong key, a key without the needed permission, a title that is too short, a missing category or topic. The note shows the message from Discourse. The add-on also never posts the same entry twice for one feed, even if a retry runs two times.

Conditions and several feeds

Use the feed condition to post only when a field has a value, for example only for the category Support. A form can have several feeds, for example a topic for the community and a private message for the team.

Security and privacy

  • The API key is encrypted with AES-256-GCM using a key derived from your WordPress salts. It is never printed in a page, a note, an entry or a log, and it is sent only in the Api-Key header, never in an address.
  • The forum address must be https. The add-on uses the WordPress safe HTTP functions, so addresses that point to private or local networks are refused. If your forum really lives on a private network, a developer can allow it with the filter gfdiscourse_allow_private_hosts.
  • The values you choose in a feed are sent to your forum. An e-mail address is sent only when you use user sync or put it in the text yourself. The add-on adds a paragraph about this to the WordPress privacy policy guide.
  • Deleting the add-on removes its settings and entry meta. Topics on the forum and the entries stay.

For developers

  • Filter gfdiscourse_job changes the title, text, category and other values before they are sent.
  • Action gfdiscourse_after_post runs after a successful post with the result, the entry, the form and the feed.
  • Filter gfdiscourse_allow_http allows an http address (for a local test forum), and gfdiscourse_allow_private_hosts allows private addresses.

Frequently asked questions

Does it work with a hosted Discourse forum?

Yes. Any Discourse forum that you can create an API key for works, hosted by Discourse or by yourself. The add-on only needs the address and the key.

Can visitors without a forum account post?

Yes. Without user sync the post is made by the API user. With user sync the add-on creates the member from the e-mail address and the name in the form.

Can it reply to a topic that was made by an earlier submission?

Yes. Use the merge tag for the topic number in a later form or feed, or store the number in a hidden field with the confirmation link.

Are uploaded files sent to the forum?

Not in version 1.0.0. Put the address of a file in the text with the {all_fields} merge tag or the field merge tag if you want the forum post to link to it.

What happens if my license expires?

The add-on keeps its settings but posts nothing and writes a note on the entry until the license is active again.

See the Discourse add-on

Still need help?

Our support team answers tickets every day, usually within a few hours.

0
0
Your Cart
Your cart is emptyReturn to Shop
🔥 FREQUENTLY BOUGHT TOGETHER
Complete Combo & Save 40%!
ITEM IN YOUR CART
Gravity Forms Klaviyo Add-on
$39.00/yr
+
🎁 RECOMMENDED ADD-ON SAVE 40% OFF
Original Price: $39.00/yr
Bundle Special Price: $23.40/yr