you should follow the below code and also see the wordpress docs
<?php
function remove_menus(){
remove_menu_page( 'index.php' ); //Dashboard
//remove_menu_page( 'jetpack' ); //Jetpack*
//remove_menu_page( 'edit.php' ); //Posts
//remove_menu_page( 'upload.php' ); //Media
//remove_menu_page( 'edit.php?post_type=page' ); //Pages
//remove_menu_page( 'edit-comments.php' ); //Comments
//remove_menu_page( 'themes.php' ); //Appearance
//remove_menu_page( 'plugins.php' ); //Plugins
//remove_menu_page( 'users.php' ); //Users
//remove_menu_page( 'tools.php' ); //Tools
//remove_menu_page( 'options-general.php' ); //Settings
}
add_action( 'admin_menu', 'remove_menus' );
?>
wordpress official docs :-
https://codex.wordpress.org/Function_Reference/remove_menu_page
page restriction at admin site for particular user
redirect when user reached there.
add_action( 'current_screen', 'restrict_screen' );
function restrict_screen() {
if ( is_admin() ) {}
else{
$current_screen = "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$indexpage="index.php";
$editpage="edit.php";
$match = strpos( $current_screen, $editpage );
$match2 = strpos( $current_screen, $indexpage );
if( $match == TRUE || $match2 == TRUE ) {
// wp_die('get out');
$current_admin = get_admin_url() . 'profile.php';
header('Location: ' . $current_admin . '', true, 301);
}
}
}