Paid user on Ghost > Add to Discourse

Hello!

I’ve been using WordPress with Memberful, and I’m now considering moving my website over to Ghost.

At this moment, I have on my WordPress/Memberful website my membership associated with Discourse. By paying my membership, the user has access to the private Discourse forum; when the membership finishes/when the user cancels the membership, automatically Memberful removes the user’s privileges on Discourse.

I’m also trying to find if it’s possible to make the same behavior on Ghost :thinking:

On Zapier, I didn’t find any way to do this; I even search for a way to connect Stripe to Discourse, without success.

1 Like

I created a custom service that actually does this. Should be ready by the end of this weekend. I’ll let you know when it’s up!

6 Likes

Do you have any updates about this? :smiley: it would be an awesome thing to Ghost!

Were you able to create the service for this? I’m currently switching away from WordPress/Memberful to Ghost as well, and this is a major hurdle.

Not exactly sure about your requirement from everyone, but the OP mentioned about automatically adding and removing Discourse user based on a user signing up as a member and canceling.

It looks like Discourse has API endpoints to manage users and groups but Discourse Zapier actions is limited(only for adding a post)
Also Ghost has Zapier events and webhooks for membership events.
Plus Zapier has the generic POST action, which can make a request to a backend(Discourse API?)

Perhaps these can be combined using one of the following options?

  1. When Zapier receives Ghost member is added/removed, it fires off a POST to Discourse API to add/remove the user
  2. You create a basic service(Express.js,etc.) that has an endpoint which Ghost will call when a member is added/removed, which then makes an https call (Axios or some other library) to Discourse API to add/remove the user

Hi there! Do you still with that project?

I know Discourse has a plugin that might help out with this.

I have a API hook that can send an invite from discourse to someone who subscribes to your newsletter on Ghost. Is that what you’re after? I don’t have the member removal but looks pretty trivial…

I think that doing automatically could be better for Customer Experience.

Yeah it does it automatically as soon as someone subscribes! Can only do invites though, the user creation api on discourse is limited in functionality…

1 Like

Hello! If anyone is still looking for this solution, I’ve got something along these lines working.

Doesn’t add user until user first visits the forum – that’s handled via DiscourseConnect automatically. My implementation doesn’t do anything with paid/free members, but I’m adding that soon.

I make no promises about it’s ruggedness.

Happy to share more details with the interested. josh @ acerlanedigital dot com.

Ops I forgot to come back to this thread as life got in the way…

This is something I threw together to run on Cloudflare Workers the other night so it’s very rough and probably not the best way to do it but it works… If you’re going to use this in production please make sure you vet the code and add some layers of security to your API to validate requests, encrypt tokens etc.

This will take an event hook from Ghost saying a new member has joined and will email them an invite code/link to your member only discourse.

addEventListener('fetch', event => {
    event.respondWith(handleRequest(event.request))
  })
  
  const config = {

    createBody: ({ id, uuid, email, name, note, geolocation, subscribed, created_at, updated_at, avatar_image, labels }) => JSON.stringify({
      email: `${email}`,
      skip_email: `false`,
      custom_message: `hi ${name}, This is your Unique invite to join our invite only Community`,
      max_redemptions_allowed: `1`,
    })
  }
  
  async function handleRequest(request) {
    const requestBody = await request.json()
    const member = requestBody.member.current
    if (!member) return new Response("Error", { status: 500 })
  
    const body = config.createBody(member)
  
    await fetch('https://YOURCOMMUNITYWEBURL.com/invites.json', {
      method: "POST",
      headers: { 
      'Content-type': 'application/json',
      'Api-Key': 'YOURSYSTEMDISCOURSEAPI',
      'Api-Username': 'system'
     },
      body
    })
    return new Response("OK")
  }
1 Like