# Manage group membership in Discourse with WP Discourse SSO

**URL:** https://meta.discourse.org/t/manage-group-membership-in-discourse-with-wp-discourse-sso/74724
**Category:** Administrators
**Tags:** groups, wordpress, payments, how-to
**Created:** [November 24, 2017, 6:55am UTC](https://meta.discourse.org/t/manage-group-membership-in-discourse-with-wp-discourse-sso/74724 "2017-11-24T06:55:17Z")
**Posts on this page:** 1
**Showing post:** 59

<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: [April 11, 2019, 4:39pm UTC](https://meta.discourse.org/t/manage-group-membership-in-discourse-with-wp-discourse-sso/74724/59 "2019-04-11T16:39:39Z")

</div>

> [@pfaffman](#):
>
> It looks like when someone places the order they might not already have a Discourse account, so hooking into the “subscription changed” hooks can’t work.

When Discourse is used as the SSO provider, you can check if a WordPress user has a Discourse account by checking if the value returned by this statement is `empty`:

```php
get_user_meta( $user_id, 'discourse_sso_user_id', true );

```

You’ll need to do something to handle the case where the user doesn’t yet have a Discourse account. Creating the user via the API and adding them to the appropriate groups is probably the right solution. It will take some work to set that up.

---

_[View the full topic](https://meta.discourse.org/t/manage-group-membership-in-discourse-with-wp-discourse-sso/74724)._
