Support » Fixing WordPress » Hide admin menu items for role

  • I would like to hide the admin menu items ‘Posts’, ‘Pages’, ‘Tools’ etc. for specific custom added roles. But I don’t only want to exclude the items from the menu, I also want to make it impossible for users to access the pages (if they know the URL or something).

    I’ve added a role using the following code:

    function roles_jrwd() {
        add_role('luitenant', 'Luitenant',
                'read' => true,
                'edit_posts' => false,
                'delete_posts' => false,
                'publish_posts' => false,
                'upload_files' => true,
    register_activation_hook( __FILE__, 'roles_jrwd' );

    Although with this code it’s still possible to edit, add and delete posts. Is there something I’m doing wrong, or did I misunderstood the codex?

Viewing 1 replies (of 1 total)
  • Have you tried using a plugin? I just did a search within WordPress Plugins ‘User roles’ and the results are on this page.

    It looks like WPFront user role editor is the most popular. But before installing I would recommend that you check that it’s compatible with your WordPress version.

Viewing 1 replies (of 1 total)
  • The topic ‘Hide admin menu items for role’ is closed to new replies.