Remove pages and other from admin panel for user with id

Mari7777777

New member
XNullUser
Joined
Mar 22, 2022
Messages
2
Reaction score
0
Points
1
NullCash
14
Add this to functions.php

Change user id to you need.

add_action( 'admin_menu', 'my_remove_menu_pages' );
function my_remove_menu_pages() {

global $user_ID;

if ( is_admin() && $user_ID == '2' ) {
remove_menu_page('edit.php');
remove_menu_page('upload.php');
remove_menu_page('link-manager.php');
remove_menu_page('edit-comments.php');
remove_menu_page('edit.php?post_type=page');
remove_menu_page('plugins.php');
remove_menu_page('themes.php');
remove_menu_page('users.php');
remove_menu_page('tools.php');
remove_menu_page('options-general.php');
?>
<style>
#adminmenu li#menu-posts-want_help, #adminmenu li#menu-posts-look_help {display: block !important;}
</style>

<?php
} if ( is_admin() && $user_ID == '1' ) {
?>
<style>
#side-sortables #want_help_catdiv, #side-sortables #look_help_catdiv {display:none !important;}
</style>

<?php
}
}
 

datlimas

Member
XNullUser
Joined
Mar 23, 2022
Messages
229
Reaction score
0
Points
16
NullCash
104
you should make users have certain roles. And give those roles permission to access only certain pages. The others will be omitted from the admin panel menu afaik.
 
Top