July 20

Hide Unused Menus In WordPress Admin

0  comments

There will be times you will need to hide certain menus from clients so they do not accidentally make changes that would affect the entire site. Here are two ways you can do it. Keep in mind that both options merely ‘hide’ the menus from the user it doesn’t actually restrict people from accessing these features IF they knew the URLs. However I would not worry too much about it. If the client was that well versed with WordPress, there would be no need to hide these menus now would there 🙂

Just so you know, these go into the active theme’s functions.php.

This code also checks for user. This code tells WordPress to hide the menus from everyone but the name of admin user.

add_action( ‘admin_init’, ‘my_remove_menu_pages’ );
function my_remove_menu_pages() {
global $menu;
global $current_user;
get_currentuserinfo();

if($current_user->user_login != ‘ADMINNAME’){
remove_menu_page(‘edit.php’);
remove_submenu_page(‘users.php’,'role-management.php’);
}
}

Source: Kevin Chard


Tags

admin, hack, menu, WordPress


You may also like

Force cPanel Password Reset

Force cPanel Password Reset
{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Get in touch

Name*
Email*
Message
0 of 350