Skip to content

Instantly share code, notes, and snippets.

@vades
Last active May 21, 2019 06:41
Show Gist options
  • Save vades/5473929a103443265d35531343fb053d to your computer and use it in GitHub Desktop.
Save vades/5473929a103443265d35531343fb053d to your computer and use it in GitHub Desktop.
Remove items from admin menu for the subscriber in WordPress

Remove items from admin menu for the subscriber

function wps_remove_menu_pages()
{
    global $user_ID;

    if (current_user_can('subscriber')) {
        remove_menu_page('edit.php'); // Posts
        remove_menu_page('upload.php'); // Media
        remove_menu_page('link-manager.php'); // Links
        remove_menu_page('edit-comments.php'); // Comments
        remove_menu_page('edit.php?post_type=page'); // Pages
        remove_menu_page('plugins.php'); // Plugins
        remove_menu_page('themes.php'); // Appearance
        remove_menu_page('users.php'); // Users
        remove_menu_page('tools.php'); // Tools
        remove_menu_page('options-general.php');
    }
}

Usage

add_action('admin_init', 'wps_remove_menu_pages');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment