The below code checks if the current user has a Membership Level and deactivates Course lock for the user.
add_filter('bp_course_api_get_user_course_status',function($return,$request){
$body = json_decode($request->get_body,true);
$user = apply_filters('vibebp_api_get_user_from_token','',$body['token']);
if(!empty($user)){
$membership_level ='abc';
if(pmpro_hasMembershipLevel($membership_id, $user->id)){
$return['lock'] = 0; // disable lock
}else{
$return['lock'] = 1; //enable lock
}
}
return $return;
},10,2);