Wordpress Dashboard für User ausstellen

Verhindert das Subscriber oder Abonomenten Zugriff auf das Wordpress backend haben.

<?php
 
 
function is_user_subscriber(){
	global $current_user;
	$is_subscriber = ( in_array( 'subscriber', $current_user->roles ) ) ? true : false;
	return $is_subscriber;
}
 
add_action( 'load-index.php','dashboard_redirect' );
function dashboard_redirect(){
	if( is_user_subscriber() ){
    	wp_redirect( admin_url( 'profile.php' ) );
	}
}
 
add_filter( 'login_redirect', 'dashboard_login_redirect' );
function dashboard_login_redirect( $url ) {
	if( is_user_subscriber() ){
		$url = wp_redirect( admin_url( 'profile.php' ) );
	}
	return $url;
}
 
add_action( 'admin_menu', 'remove_dashboard', 99 );
function remove_dashboard(){
	if( is_user_subscriber() ){
		remove_menu_page( 'index.php' );
	}
}