Have a look at this:
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;
}
}