Bring over permission level from WordPress MemberPress

Thanks for the quick response @simon. I think I am going to try to go with the first option. Because the free membership isn’t setup on the live WordPress site yet, I am having a hard time testing this. Here is the code that I have now:

add_filter( 'wpdc_sso_params', 'wpdc_custom_sso_params', 10, 2 );
function wpdc_custom_sso_params( $params, $user ) {
    if ( current_user_can('mepr-active','memberships:12856') ) {
      $params['add_groups'] = 'Academy_Free'; // Don't use spaces between names.
    } else {
      $params['remove_groups'] = 'Academy_Free'; // Don't use spaces between names.
    }

    return $params;
}

current_user_can('mepr-active','memberships:12856) is a function in MemberPress that checks if a member is active in a specific membership. Does that look right? If so, that code runs every time someone connects to Discourse via SSO, correct? If this looks right, I may wait until we push the free membership live and then test this functionality—unless you have a way we could test it now with a WP staging site.

Thanks!

1 Like