/wordpress/plugins/membership/membershipincludes/includes/functions.php
function M_set_level_operations( $levels ) {
global $M_add_level;
$user = wp_get_current_user();
if(count($levels) >= 20) {
$M_add_level = false;
$user->remove_cap('M_add_level');
} else {
$M_add_level = true;
$user->add_cap('M_add_level');
}
}