yan-k
1/4/2014 - 1:06 PM

How to Remove Menu Items in Admin Depending on User Role. Examples of pages in the Wordpress Admin: remove_menu_page('edit.php'); // Posts

How to Remove Menu Items in Admin Depending on User Role.

Examples of pages in the Wordpress Admin: 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'); // Settings

add_action( 'admin_init', 'my_remove_menu_pages' );
function my_remove_menu_pages() {
 
    global $user_ID;
 
    if ( current_user_can( 'wpmayorauthor' ) ) {
    remove_menu_page( 'edit.php?post_type=thirstylink' );
    remove_menu_page( 'edit.php?post_type=wprss_feed' );
        remove_menu_page( 'authorhreview' );
    }
}

/** Examples of pages in the Wordpress Administration
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'); // Settings
**/