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
On Zapier, I didn’t find any way to do this; I even search for a way to connect Stripe to Discourse, without success.
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?
When Zapier receives Ghost member is added/removed, it fires off a POST to Discourse API to add/remove the user
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
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…
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…
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")
}