# Memberpress：如何在注册时将用户添加到组

**URL:** <https://meta.discourse.org/t/memberpress-how-to-add-users-to-groups-upon-sign-up/83478>\
**Category:** WordPress\
**Created:** [2018年三月21日 13:48 UTC](https://meta.discourse.org/t/memberpress-how-to-add-users-to-groups-upon-sign-up/83478 "2018-03-21T13:48:54Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Dani1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dani1/32/84172_2.png) [@Dani1](https://meta.discourse.org/u/Dani1)\
**Post date:** [2018年四月3日 09:56 UTC](https://meta.discourse.org/t/memberpress-how-to-add-users-to-groups-upon-sign-up/83478/7 "2018-04-03T09:56:49Z")

</div>

In the parallel post on this topic ([Bring over permission level from WordPress MemberPress - #16 by Dani1](https://meta.discourse.org/t/bring-over-permission-level-from-wordpress-memberpress/78074/16)) I came to the following code (this one corrected for curly quotes).

The below code adds people to their corresponding Discourse group when signing up through Memberpress.

BUT.

when they up- or downgrade, it adds them to the new group, but it does NOT remove them from their previous group.

@simon  
Simon, any idea how to adjust for that?

Thanks!

```plaintext
add_filter( 'wpdc_sso_params', 'wpdc_custom_sso_params' );
function wpdc_custom_sso_params( $params ) {
	if ( current_user_can( 'mepr-active','memberships:47281' ) ) {
		$params['add_groups'] = 'ForeverFree';
	} else {
		$params['remove_groups'] = 'ForeverFree';
	}

	if ( current_user_can( 'mepr-active','memberships:47295,47297' ) ) {
		$params['add_groups'] = 'CreativeLicense';
	} else {
		$params['remove_groups'] = 'CreativeLicense';
	}

	if ( current_user_can( 'mepr-active','memberships:47299,47301' ) ) {
		$params['add_groups'] = 'JoinLive';
	} else {
		$params['remove_groups'] = 'JoinLive';
	}

	if ( current_user_can( 'mepr-active','memberships:47303,47305' ) ) {
		$params['add_groups'] = 'Transform';
	} else {
		$params['remove_groups'] = 'Transform';
	}

	if ( current_user_can( 'mepr-active','memberships:48259,48238' ) ) {
		$params['add_groups'] = 'TransformPlus';
	} else {
		$params['remove_groups'] = 'TransformPlus';
	}

	return $params;
}

```

---

_[View the full topic](https://meta.discourse.org/t/memberpress-how-to-add-users-to-groups-upon-sign-up/83478)._
