How do I set-up this workflow? Membership form with Payment > Discourse Invite

Hi, I run a nonprofit community that has this workflow.

  1. Someone applies to join the nonprofit community via a form of some kind

  2. As part of the application, they are asked to make a donations based contribution that’s up to them, from $0 to the sky’s the limit

  3. After submitting their membership application, I’d like a setup that automatically sends them a Discourse invite to our private Discourse forum

How do I set-up this workflow?

3 Likes

One side of this is that you can generate invite links via the API and make your community require login / approval. Do you have someone doing dev on your side, it is going to require a little bit of coding.

1 Like

We have some dev talent. Is there example code or documentation, though, that perhaps another discourse forum uses, that we can borrow from?

You can send an invite through the Discourse API by making a POST request to https://forum.example.com/invites

In the body of the request you need to include the All Users api_key and api_username. The All Users api_username defaults to ‘system’. The other parameter that you need to include is email. You can optionally include a custom_message and a group_names parameter. The group_names parameter should be set to a comma separated list (without spaces) of group names for groups that already exist on your forum.

Here is an example API call made with curl. $api_key is set to the All Users API key for my forum. The URL is the URL of my local development forum:

curl -X POST -d "api_key=$api_key&api_username=system&email=johndoe@example.com&custom_message=Thanks for your contribution." http://localhost:3000/invites

The response you should get for a successful invite is {"success":"OK"}.

Once you have this working with curl or Postman, it should be possible to wire up your application to make the request automatically when a user makes a contribution.

You can customize the email templates that are used for sending these invites. The template that is used if a custom message is included is the Custom Invite Forum Mailer template. The template that is used when a custom message is not included is the Invite Forum Mailer.

For details about finding which API request to make to perform a specific action, see the How to reverse engineer the Discourse API topic. For details about customizing email templates, see the How to customize email templates topic.

7 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.