# Paid Memberships Pro sync with groups

**URL:** https://meta.discourse.org/t/paid-memberships-pro-sync-with-groups/108260
**Category:** WordPress
**Created:** [03.Февраль.2019 20:12:26 UTC](https://meta.discourse.org/t/paid-memberships-pro-sync-with-groups/108260 "2019-02-03T20:12:26Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![PatrickH](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/patrickh/32/116296_2.png) [@PatrickH](https://meta.discourse.org/u/PatrickH)
#### Post date: [03.Февраль.2019 20:12:26 UTC](https://meta.discourse.org/t/paid-memberships-pro-sync-with-groups/108260/1 "2019-02-03T20:12:26Z")

</div>

Is there a way that the wordpress discourse plugin can sync the users memberships level (aka trustlevel) ?  
So if they pay for a premium membership that this plugin also sync this ?  
Thanks for your help.

---

<div class="post-metadata">

### Author: ![bts](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bts/32/184556_2.png) [@bts](https://meta.discourse.org/u/bts)
#### Post date: [03.Февраль.2019 21:31:46 UTC](https://meta.discourse.org/t/paid-memberships-pro-sync-with-groups/108260/2 "2019-02-03T21:31:46Z")

</div>

Yep, this is definitely possible, requires just a small amount of custom code. Each membership plugin works slightly differently but essentially you just need to hook into the WordPress actions that fire when a membership is created / edited, and have it fire the built in [WP Discourse](https://github.com/discourse/wp-discourse) functions to add or remove members from a group. See here for details and example code:

> [@Manage group membership in Discourse with WP Discourse SSO](https://meta.discourse.org/t/managing-discourse-group-membership-with-wp-discourse/74724):
>
> [WP Discourse](https://github.com/discourse/wp-discourse) functions The [WP Discourse](https://github.com/discourse/wp-discourse) plugin has a couple of functions that can be used to associate WordPress users with Discourse groups. These functions are only enabled on sites that are using WordPress as the SSO provider for Discourse. add\_user\_to\_discourse\_group( $user\_id, $group\_names ) [View Code](https://github.com/discourse/wp-discourse/blob/main/lib/utilities.php#L278-L301) remove\_user\_from\_discourse\_group( $user\_id, $group\_names ) [View Code](https://github.com/discourse/wp-discourse/blob/main/lib/utilities.php#L303-L326) Each of these functions take the same two parameters: $user\_id: the WordPress user’s id $group\_names: a comma separat…
