admin管理员组文章数量:1334667
How to remove elementor from wordpress admin menu. I have tried below option but it didnt work.
add_action( 'admin_menu', 'my_remove_menu_pages' );
function my_remove_menu_pages() {
remove_menu_page( 'edit.php?post_type=elementor_library' );
//Elementor
};
How to remove elementor from wordpress admin menu. I have tried below option but it didnt work.
add_action( 'admin_menu', 'my_remove_menu_pages' );
function my_remove_menu_pages() {
remove_menu_page( 'edit.php?post_type=elementor_library' );
//Elementor
};
Share
Improve this question
edited Jul 10, 2018 at 17:01
Krzysiek Dróżdż
25.5k9 gold badges53 silver badges74 bronze badges
asked Jul 10, 2018 at 14:32
Amit JugranAmit Jugran
1311 silver badge9 bronze badges
3 Answers
Reset to default 3This would work for editors. You can swap the role in and out depending on which role you are trying to target (e.g., editor
, subscriber
, etc.). This would go in functions.php
of your child theme.
function remove_menus(){
// get current login user's role
$roles = wp_get_current_user()->roles;
// test role
if( !in_array('editor',$roles)){
return;
}
//remove menu from site backend.
remove_menu_page( 'edit.php?post_type=elementor_library' ); // Elementor Templates
remove_menu_page( 'elementor' ); // Elementor
}
add_action( 'admin_menu', 'remove_menus' , 100 );
I have been able to do it using 'admin_init'
action. The correct code is below
add_action( 'admin_init', 'my_remove_menu_pages' );
function my_remove_menu_pages() {
global $user_ID;
if ( current_user_can( 'subscriber' ) )
{
remove_menu_page( 'edit.php?post_type=elementor_library' );
remove_menu_page( 'elementor' );
}
}
However, I am not able to restrict it for a specific user role. The above code restricts it for all user roles, including admin.
I am using a multisite install. so if anyone knows to restrict it for a user role on multisite install, please add the necessary bit of code.
Thanks.
This code works for admins only.
add_action( 'admin_init', 'my_remove_menu_pages' );
function my_remove_menu_pages($query) {
$current_user = wp_get_current_user();
if($current_user->ID == 1) //Aqui é o meu ID. Vai ocultar a página pra todos menos pra esse ID
return $query;
remove_menu_page( 'edit.php?post_type=elementor_library' );
remove_menu_page( 'elementor' );
}
本文标签: Remove Elementor Menu From Wordpress Admin
版权声明:本文标题:Remove Elementor Menu From Wordpress Admin 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742373001a2462604.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论