Here is a snipped. Make sure to run this code after the users are logged in
//To get logged in user information
$user = wp_get_current_user();
//Condition to check weather user is subscriber or not
if ( in_array( 'subscriber', (array) $user->roles ) ) {
//The user has the "subscriber" role
}else{
// redirect user to different section and end their session
wp_logout(); // user is logged out
wp_redirect( home_url( "https://wordpress.stackexchange.com/" ) ); // user is redirected to home page
}
Do let me know if this works for you or not