0
votes

i know about the way to show/hide menu items in admin based on user roles, but anyone can just type the address and access the specific menu. I was wondering if there is a way to restrict that as well.

For the moment i'm using this code:

add_action( 'admin_init', 'my_remove_menu_pages' );

function my_remove_menu_pages() {
    // If the user does not have access to publish posts
    if(!current_user_can('add_users')) {
        // Remove the "Tools" menu
        remove_menu_page('tools.php');
    }
}
1

1 Answers