I need to hide / remove a menu and submenu in WordPress backend.
Main menu item:
admin.php?page=themeit_dashboard
Sub menu items:
admin.php?page=themeit_dashboard&tab=builder
admin.php?page=_options&tab=1
admin.php?page=themeit_dashboard&tab=license
I have tried the code below code, but that does not work. Two of the subpages link to the same page but show different tabs.
function remove_menus(){
if ( !current_user_can( 'manage_options' ) ) {
remove_menu_page( 'admin.php?page=themeit_dashboard' ); //themeit
remove_submenu_page( 'admin.php?page=themeit_dashboard', 'admin.php?page=themeit_dashboard&tab=builder' ); //themeit
remove_submenu_page( 'admin.php?page=_options', 'admin.php?page=_options&tab=1' ); //themeit
remove_submenu_page( 'admin.php?page=themeit_dashboard', 'admin.php?page=themeit_dashboard&tab=license' ); //themeit
}
}
add_action( 'admin_menu', 'remove_menus' );
add_action( 'admin_menu', 'remove_menus', 99 );- Shravan Sharma