# WordPress Membership Integration (Private Forum) with Discourse

**URL:** https://meta.discourse.org/t/wordpress-membership-integration-private-forum-with-discourse/91438
**Category:** WordPress
**Created:** [July 3, 2018, 3:36am UTC](https://meta.discourse.org/t/wordpress-membership-integration-private-forum-with-discourse/91438 "2018-07-03T03:36:47Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![JeremyC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jeremyc/32/119775_2.png) [@JeremyC](https://meta.discourse.org/u/JeremyC)
#### Post date: [July 3, 2018, 3:36am UTC](https://meta.discourse.org/t/wordpress-membership-integration-private-forum-with-discourse/91438/1 "2018-07-03T03:36:47Z")

</div>

We’re in the midst of changing forums from BBPress to Discourse. We have a Membership based website on WordPress using WooMembership with 2 levels of member access (they all get the forums), except if they cancel their subscription/membership.

I want to know if its possible with the current [WP Discourse](https://github.com/discourse/wp-discourse) plugin to ensure that ONLY paying members are allowed to enter the forum?

If so, is everything done through the plugin?

Thanks,

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [July 3, 2018, 7:23pm UTC](https://meta.discourse.org/t/wordpress-membership-integration-private-forum-with-discourse/91438/2 "2018-07-03T19:23:15Z")

</div>

> [@JeremyC](#):
>
> I want to know if its possible with the current [WP Discourse](https://github.com/discourse/wp-discourse) plugin to ensure that ONLY paying members are allowed to enter the forum?

Yes, if you use your WordPress site as the SSO provider for your forum, there is an action hook that you can use to limit which users are able to login to the forum. The hook is called `wpdc_sso_provider_before_sso_redirect`. Some code like this, added to a plugin or your theme’s `functions.php` file will work. You will need to figure out how to check the user’s WooMembership level.

```plaintext
add_action( 'wpdc_sso_provider_before_sso_redirect', 'wpdc_custom_check_user_membership', 10, 2 );
function wpdc_custom_check_user_membership( $user_id, $user ) {
    if ( /* Some condition that returns true if the user doesn't meet the membership requirement */ ) {
	    wp_safe_redirect( home_url() );

	    exit;

    }
}

```

---

<div class="post-metadata">

### Author: ![JeremyC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jeremyc/32/119775_2.png) [@JeremyC](https://meta.discourse.org/u/JeremyC)
#### Post date: [July 4, 2018, 12:31am UTC](https://meta.discourse.org/t/wordpress-membership-integration-private-forum-with-discourse/91438/3 "2018-07-04T00:31:50Z")

</div>

Simon,

Is this something you would be interested in getting paid to do for me? And setup properly?

---

<div class="post-metadata">

### Author: ![JeremyC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jeremyc/32/119775_2.png) [@JeremyC](https://meta.discourse.org/u/JeremyC)
#### Post date: [July 4, 2018, 12:32am UTC](https://meta.discourse.org/t/wordpress-membership-integration-private-forum-with-discourse/91438/4 "2018-07-04T00:32:30Z")

</div>

And of course, thank you for that response – it looks like it’s very doable and gives me confidence that this is something that can be done.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [July 4, 2018, 12:57am UTC](https://meta.discourse.org/t/wordpress-membership-integration-private-forum-with-discourse/91438/5 "2018-07-04T00:57:29Z")

</div>

I can’t take on any private work, but I can give you some help through this forum. Most of what you are looking to do is provided by the [WP Discourse](https://github.com/discourse/wp-discourse) plugin out of the box. By default, the [WP Discourse](https://github.com/discourse/wp-discourse) plugin will give all users on your WordPress site access to your Discourse forum. To limit access to users who have purchased a membership, we just need to know how to fill in this part of the code that I posted above:

```plaintext
/* Some condition that returns true if the user doesn't meet the membership requirement */

```

How to get the membership level for a user is documented here: [https://docs.woocommerce.com/document/woocommerce-memberships-function-reference/#section-6](https://docs.woocommerce.com/document/woocommerce-memberships-function-reference/#section-6). Anyone who has some experience with WordPress programming should be able to help with this. It won’t require any knowledge of Discourse to figure it out.

---

<div class="post-metadata">

### Author: ![JeremyC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jeremyc/32/119775_2.png) [@JeremyC](https://meta.discourse.org/u/JeremyC)
#### Post date: [July 4, 2018, 1:01am UTC](https://meta.discourse.org/t/wordpress-membership-integration-private-forum-with-discourse/91438/6 "2018-07-04T01:01:04Z")

</div>

Got it – thanks for your help – looks straight forward. I’m looking at the hosted Discourse, $100/mo - is that the plan that would be easiest to connect with the plugin and run the forum?

I just want to make sure that, they can only access the forum via going to the main website, and they can’t just access the forum without logging in via website or cancelled their membership.

Thanks,

---

<div class="post-metadata">

### Author: ![HAWK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hawk/32/86627_2.png) [@HAWK](https://meta.discourse.org/u/HAWK)
#### Post date: [July 4, 2018, 3:07am UTC](https://meta.discourse.org/t/wordpress-membership-integration-private-forum-with-discourse/91438/7 "2018-07-04T03:07:02Z")

</div>

> [@JeremyC](#):
>
> ’m looking at the hosted Discourse, $100/mo - is that the plan that would be easiest to connect with the plugin and run the forum?

Yes, that will work fine.

---

<div class="post-metadata">

### Author: ![JeremyC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jeremyc/32/119775_2.png) [@JeremyC](https://meta.discourse.org/u/JeremyC)
#### Post date: [July 6, 2018, 3:55am UTC](https://meta.discourse.org/t/wordpress-membership-integration-private-forum-with-discourse/91438/8 "2018-07-06T03:55:42Z")

</div>

Hey,

I just want to give an update here.

We have go ahead and did the $100/mo plan. And we have coded it so that it works and detects membership plan levels.

So everything is good, and looks like its working properly.

Thank you very much for your help.

---

<div class="post-metadata">

### Author: ![dfriestedt](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@dfriestedt](https://meta.discourse.org/u/dfriestedt)
#### Post date: [March 22, 2019, 9:39am UTC](https://meta.discourse.org/t/wordpress-membership-integration-private-forum-with-discourse/91438/9 "2019-03-22T09:39:20Z")

</div>

> [@JeremyC](#):
>
> And we have coded it so that it works and detects membership plan levels.

I’m looking to do the same. Would you be willing to share your final code for:

```
/* Some condition that returns true if the user doesn't meet the membership requirement */

```

---

<div class="post-metadata">

### Author: ![JeremyC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jeremyc/32/119775_2.png) [@JeremyC](https://meta.discourse.org/u/JeremyC)
#### Post date: [March 23, 2019, 2:57am UTC](https://meta.discourse.org/t/wordpress-membership-integration-private-forum-with-discourse/91438/10 "2019-03-23T02:57:14Z")

</div>

Yes, not an issue - I will replace some numbers with 99, and the url with a fake URL.

I have attached it here.[code.txt](https://global.discourse-cdn.com/meta/original/3X/6/4/64ff7397a13b877c14ed1040d99254f704de5447.txt) (595 Bytes)

Hope this helps.

---

<div class="post-metadata">

### Author: ![alexjpanagis](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alexjpanagis/32/263387_2.png) [@alexjpanagis](https://meta.discourse.org/u/alexjpanagis)
#### Post date: [June 2, 2019, 11:51am UTC](https://meta.discourse.org/t/wordpress-membership-integration-private-forum-with-discourse/91438/11 "2019-06-02T11:51:55Z")

</div>

Hi @JeremyC, I’m considering doing something similar. Would you be able to share your experiences with it? I’d love to talk about it to see if this is a good fit…

---

<div class="post-metadata">

### Author: ![JeremyC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jeremyc/32/119775_2.png) [@JeremyC](https://meta.discourse.org/u/JeremyC)
#### Post date: [June 2, 2019, 1:34pm UTC](https://meta.discourse.org/t/wordpress-membership-integration-private-forum-with-discourse/91438/12 "2019-06-02T13:34:43Z")

</div>

Hey, I posted my experience on Mar 22 and attached the code for it in the txt file.

> [@WordPress Membership Integration (Private Forum) with Discourse](https://meta.discourse.org/t/wordpress-membership-integration-private-forum-with-discourse/91438/10):
>
> Yes, not an issue - I will replace some numbers with 99, and the url with a fake URL. I have attached it here.[code.txt](https://global.discourse-cdn.com/meta/original/3X/6/4/64ff7397a13b877c14ed1040d99254f704de5447.txt) (595 Bytes) Hope this helps.

Cheers,

---

<div class="post-metadata">

### Author: ![chrislamdesign](https://avatars.discourse-cdn.com/v4/letter/c/e9a140/32.png) [@chrislamdesign](https://meta.discourse.org/u/chrislamdesign)
#### Post date: [July 6, 2020, 9:23pm UTC](https://meta.discourse.org/t/wordpress-membership-integration-private-forum-with-discourse/91438/13 "2020-07-06T21:23:55Z")

</div>

I know this is an old thread. I’m looking to integrate this same flow (user signs up via woo memberships and has access to discourse forum). However, client does not want to use WordPress as the SSO provider. Is this still possible?

Thanks for you any insight!

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [July 6, 2020, 9:40pm UTC](https://meta.discourse.org/t/wordpress-membership-integration-private-forum-with-discourse/91438/14 "2020-07-06T21:40:16Z")

</div>

> [@chrislamdesign](#):
>
> I’m looking to integrate this same flow (user signs up via woo memberships and has access to discourse forum). However, client does not want to use WordPress as the SSO provider.

A couple of possible approaches that don’t use SSO:

- Send users an invite to the forum through the Discourse API when the user signs up via Woo Memberships. It might be possible to use Zapier for this: [Automate sending Discourse invite emails with Zapier](https://meta.discourse.org/t/automate-sending-discourse-invite-emails-with-zapier/121608)

- Create a Discourse user and/or add them to a Discourse group when the user signs up via Woo Memberships. This could be done with the Discourse API. It will be tricker to implement than just sending an invitation to the forum, but since you might want to also be able to _remove_ the user from a group when their membership expires, it could be worth looking into this approach.

---

<div class="post-metadata">

### Author: ![chrislamdesign](https://avatars.discourse-cdn.com/v4/letter/c/e9a140/32.png) [@chrislamdesign](https://meta.discourse.org/u/chrislamdesign)
#### Post date: [July 6, 2020, 9:57pm UTC](https://meta.discourse.org/t/wordpress-membership-integration-private-forum-with-discourse/91438/16 "2020-07-06T21:57:14Z")

</div>

Thank you! Is there any docs for the second bullet point? Using the Discourse API?

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [July 6, 2020, 10:03pm UTC](https://meta.discourse.org/t/wordpress-membership-integration-private-forum-with-discourse/91438/17 "2020-07-06T22:03:23Z")

</div>

> [@chrislamdesign](#):
>
> Is there any docs for the second bullet point? Using the Discourse API?

I would start here: [How to reverse engineer the Discourse API](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576). For details about creating users, have a look at [https://docs.discourse.org/](https://docs.discourse.org/). Search for ‘user’ in the docs to get details about how to create a user via the API.

There is also a lot of information available in posts on Meta. Here’s a search to get you started with that: [Search results for 'create user API' - Discourse Meta](https://meta.discourse.org/search?expanded=true&q=create%20user%20API).
