Based on David Carson’s snippet for making the website available only for users, came up with this and it does the job for me so…. maybe others will find it useful:
// Declare Ban Users by Role function
function ban_user(){
global $bp, $bp_unfiltered_uri;
// If user is logged in and
if (is_user_logged_in() &&
(
// The current user role is banned
current_user_can('banned')
)
) {
// Display the error message
wp_die('You are banned.');
}
}