# 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:** 81

<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: [May 31, 2019, 10:08pm UTC](https://meta.discourse.org/t/manage-group-membership-in-discourse-with-wp-discourse-sso/74724/81 "2019-05-31T22:08:50Z")

</div>

> [@dylanb](#):
>
> My understanding is that this code only fires when users buy subscription or cancel a subscription.

The `add_user_to_discourse_groups` function will create a Discourse user if it doesn’t already exist. If that function is being called for your users, then you should be fine. Where you might run into problems will be for existing WordPress users who got their membership before the code was added to your site. If that is the case, you will probably need to add the users to Discourse groups through the SSO parameters that are passed to Discourse on login.

To pass additional SSO parameters with the [WP Discourse](https://github.com/discourse/wp-discourse) plugin, you can hook into the `'wpdc_sso_params'` filter. The parameter you need to use to add users to a Discourse group is called `add_groups`. You can use it with something like this:

```php
add_filter( 'wpdc_sso_params', 'wpdc_custom_sso_params', 10, 2 );
function wpdc_custom_sso_params( $params, $user ) {
    if ( /* some condition that returns true if groups should be added for the user */ ) {
        $params['add_groups'] = 'comma,separated,group,names'; // Don't use spaces between names.
    }

    return $params;
}

```

---

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