# Please Check Code For Assigning Group to WooCommerce Memberships Members

**URL:** <https://meta.discourse.org/t/please-check-code-for-assigning-group-to-woocommerce-memberships-members/113013>\
**Category:** Product Support\
**Created:** [30 maart 2019 om 16:20 UTC](https://meta.discourse.org/t/please-check-code-for-assigning-group-to-woocommerce-memberships-members/113013 "2019-03-30T16:20:51Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Corsterix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/corsterix/32/135849_2.png) [@Corsterix](https://meta.discourse.org/u/Corsterix)\
**Post date:** [3 april 2019 om 12:55 UTC](https://meta.discourse.org/t/please-check-code-for-assigning-group-to-woocommerce-memberships-members/113013/3 "2019-04-03T12:55:48Z")

</div>

Have a look at this:

[https://github.com/scossar/wp-discourse-woocommerce-support](https://github.com/scossar/wp-discourse-woocommerce-support)

and this:

```
//check membership for forum login
add_action( 'wpdc_sso_provider_before_sso_redirect', 'wpdc_custom_check_user_membership', 99, 99 );
function wpdc_custom_check_user_membership( $user_id, $user ) {
    
    $args = array( 
        'status' => array( 'active', 'complimentary' ),
    );
    
    $memberships = wc_memberships_get_user_active_memberships($user_id, $args);
    
    if ( empty( $memberships ) /* Some condition that returns true if the user doesn't meet the membership requirement */ ) {
        
        wp_safe_redirect( 'https://abc.com' );
        exit;
    }
}

```

---

_[View the full topic](https://meta.discourse.org/t/please-check-code-for-assigning-group-to-woocommerce-memberships-members/113013)._
