admin管理员组文章数量:1122832
I have managed successfully to remove the not needed menu items for user role 'editor'. Now I have one item left on the top bar that makes Editor add new post page and other items which I need to hide. Please check the screen shot as I indicate what item is this. There is a link of this page displayed and I tried but it does not want to go away.
I have used the code:
/** remove editor dashboard menu */ define( 'DISALLOW_FILE_EDIT', true);
function remove_menus(){
remove_menu_page( 'upload.php' ); //Media
remove_menu_page( 'edit.php?post_type=page' ); //Pages
remove_menu_page( 'themes.php' ); //Appearance
remove_menu_page( 'post.php' ); //Remove +New
remove_menu_page( 'post-new.php' ); //Remove +New
remove_submenu_page( 'post-new.php' ); //Edit Page
remove_menu_page( 'edit.php?post_type=client' ); //Clients
remove_menu_page( 'edit.php?post_type=offer' ); //Offers
remove_menu_page( 'edit.php?post_type=portfolio' ); //Portfolio
remove_menu_page( 'edit.php?post_type=slide' ); //Slides
remove_menu_page( 'edit.php?post_type=testimonial' ); //Testimonials
remove_menu_page( 'edit.php?post_type=layout' ); //Layouts
remove_menu_page( 'edit.php?post_type=template' ); //Templates
remove_menu_page( 'wpcf7' ); //Contacts
remove_menu_page( 'tools.php' ); //Tools
remove_menu_page( 'vc-welcome' ); //Visual Composer
remove_menu_page( 'options-general.php' ); //Settings remove_menu_page(
'wpcf7' ); //contact form
} if(current_user_can( 'editor' )){ add_action( 'admin_menu', 'remove_menus' ); }
So I tried to use:
remove_menu_page( 'post-new.php' ); //Remove +New
remove_submenu_page( 'post-new.php' ); //Edit Page
but it does not work. How could I remove this menu item with all its submenus?
I have managed successfully to remove the not needed menu items for user role 'editor'. Now I have one item left on the top bar that makes Editor add new post page and other items which I need to hide. Please check the screen shot as I indicate what item is this. There is a link of this page displayed and I tried but it does not want to go away.
I have used the code:
/** remove editor dashboard menu */ define( 'DISALLOW_FILE_EDIT', true);
function remove_menus(){
remove_menu_page( 'upload.php' ); //Media
remove_menu_page( 'edit.php?post_type=page' ); //Pages
remove_menu_page( 'themes.php' ); //Appearance
remove_menu_page( 'post.php' ); //Remove +New
remove_menu_page( 'post-new.php' ); //Remove +New
remove_submenu_page( 'post-new.php' ); //Edit Page
remove_menu_page( 'edit.php?post_type=client' ); //Clients
remove_menu_page( 'edit.php?post_type=offer' ); //Offers
remove_menu_page( 'edit.php?post_type=portfolio' ); //Portfolio
remove_menu_page( 'edit.php?post_type=slide' ); //Slides
remove_menu_page( 'edit.php?post_type=testimonial' ); //Testimonials
remove_menu_page( 'edit.php?post_type=layout' ); //Layouts
remove_menu_page( 'edit.php?post_type=template' ); //Templates
remove_menu_page( 'wpcf7' ); //Contacts
remove_menu_page( 'tools.php' ); //Tools
remove_menu_page( 'vc-welcome' ); //Visual Composer
remove_menu_page( 'options-general.php' ); //Settings remove_menu_page(
'wpcf7' ); //contact form
} if(current_user_can( 'editor' )){ add_action( 'admin_menu', 'remove_menus' ); }
So I tried to use:
remove_menu_page( 'post-new.php' ); //Remove +New
remove_submenu_page( 'post-new.php' ); //Edit Page
but it does not work. How could I remove this menu item with all its submenus?
Share Improve this question edited Jan 31, 2020 at 10:46 Jessica217 asked Jan 31, 2020 at 10:20 Jessica217Jessica217 111 silver badge3 bronze badges1 Answer
Reset to default 1Use this example
function my_admin_bar_render() {
$user = wp_get_current_user();
if ( in_array( 'editor', (array) $user->roles ) ) {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('new-content');
}
}
add_action( 'wp_before_admin_bar_render', 'my_admin_bar_render' );
本文标签: Removing wp admin menu item on top bar of admin backend
版权声明:本文标题:Removing wp admin menu item on top bar of admin backend 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736309268a1933959.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论