On the backend of a WordPress site, the admin menu looks like this:
Dashboard
Media
Pages
Pluginname
–– Edit
–– Short Code
–– Settings
–– FAQs
I would like to hide Pluginname/Settings from one admin. Since hovering over Pluginname/Settings shows https://url.xy/wp-admin/edit.php?post_type=pluginname&page=plg_settings , i added these lines of code to the functions.php file:
add_action( 'admin_init', 'my_remove_menu_pages' );
function my_remove_menu_pages() {
global $user_ID;
if ( $user_ID == 2 ) {
remove_menu_page( 'pluginname.php' , 'plg_settings.php' );
}
}
But this does not do anything.
Does anybody have advice for me?
2
Answers
Thanks to the hint from speshock I could find the solution. I had to use remove_submenu_page instead of remove_menu_page:
If your not looking at functions code I really recommend just using the admin menu editor. https://wordpress.org/plugins/admin-menu-editor/ It will allow you to change the name of the links, the icons, the permissions and so many more options. Hope that it works out for you