Using Discourse with s2member

Hi team,

I have my Discourse forum connected to my Wordpress site via SSO.

Users get access to my Discourse forum (as well as my Wordpress site) as part of a paid membership. I am using s2member as my Wordpress membership plugin.

If someone cancels their membership, ideally they would also lose access to my Discourse forum.

The way s2member functions, if someone cancels their membership, they are automatically downgraded from a Level 1 member to a Free Subscriber. This works great on my Wordpress website, but there is no “communication” with Discourse…so that user who cancelled would lose access to my Wordpress site, but still have access to the forum.

I’m curious if there is a way of automatically removing/downgrading users who cancel from my Discourse forum?

Thanks for any ideas. Much appreciated! :v:

Generally, there is a hook in WordPress that gets called when someone changes level and you use that to make an API call to change their group membership in discourse.

Yes - @simon wrote a plugin that suspends and/or moves a user in or out of a group in Discourse and it works in conjunction with the WP-Discourse plugin and Paid Memberships Pro. It’s incomplete at the moment as it has some inconsistent behavior and possibly is hindered by rate limits of Discourse.

See this thread for a discussion about the rationale of suspending users in this scenario:

3 Likes

The WordPress plugin has a couple of functions that can be used to add and remove members from Discourse groups. You will need to write some code, or get someone to write some code for you, in order to use them. There is some information about how to do it here: Managing Discourse group membership with WP Discourse

There are some issues with rate-limiting when these functions are used. They will fail if you are trying to add or remove many users at the same time. I’m going to change the function’s code to solve this problem ( change them to use the sync_sso route instead of making API calls.) The function’s interface won’t change, so it’s safe to try them now.

3 Likes

Thanks guys for the replies. Much appreciated!