简体   繁体   English

如何隐藏 Wordpress 仪表板中的管理菜单项?

[英]How do I hide the Admin Menu item in Wordpress Dashboard?

I'm trying to hide the Wordpress admin menu sub menu item.我试图隐藏 Wordpress 管理菜单子菜单项。

I have tried various snippets found here on StackOverflow and on Wordpress in functions.php , but nothing is working.我已经尝试了在 StackOverflow 和 Wordpress 上的functions.php找到的各种片段,但没有任何效果。

This is the url to the page I want to hide: wp-admin/admin.php?page=be-websites这是我想隐藏的页面的 url: wp-admin/admin.php?page=be-websites

The reason the other code snippet which included remove_menu_page() did not work was that it targets top level admin menu items whereas remove_submenu_page will remove the submenu pages just as the function name suggests.包含remove_menu_page()的其他代码片段remove_menu_page()的原因是它针对顶级管理菜单项,而remove_submenu_page将删除子菜单页面,正如函数名称所暗示的那样。

the first parameter the function takes is the slug for the parent menu and the second is the slug for the sub menu you want to remove.该函数采用的第一个参数是父菜单的 slug,第二个参数是要删除的子菜单的 slug。 Source 来源

Note: This function simply removes the menu it does not replace filtering users' permissions注意:此功能只是删除菜单,它不会替换过滤用户的权限

function remove_admin_menu_items(){
    remove_submenu_page( 'admin.php', 'be-websites' );
}
add_action('admin_menu', 'remove_admin_menu_items', 999);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM