my code stock.com

Hide unnecessary menu item for everyone except admins.

Snippet options

Download: Download snippet as admin-menu.php.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

<?php 
if(!current_user_can('manage_options')) {
     function rg_cleanBackendForUsers() {
        global $menu;

        remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
        remove_menu_page('options-general.php' );
        remove_menu_page('tools.php' );
        remove_menu_page('themes.php' );
        remove_menu_page('shortcodes-ultimate');
        remove_menu_page('wpcf7');
        remove_menu_page('easy-modal' );
        remove_menu_page('tablepress');
        remove_menu_page('te_announcements'); // Timeline Express
        remove_menu_page('edit.php?post_type=sidebar' );
        remove_menu_page('edit.php?post_type=wpdmpro' );
        remove_menu_page('edit.php?post_type=te_announcements');
        remove_menu_page('edit-comments.php');
        remove_menu_page('menu-posts-cptbc');
        remove_menu_page('admin.php?page=extensions.php');
        remove_menu_page('edit.php?post_type=ditty_news_ticker');
        remove_menu_page('menu-posts-te_announcements');
        remove_menu_page('edit.php?post_type=cptbc'); // Karrusell
    }
}

add_action('admin_menu','rg_cleanBackendForUsers', 100);

if (!function_exists('debug_admin_menus')):
function debug_admin_menus() {
if ( !is_admin())
        return;
    global $submenu, $menu, $pagenow;
    if ( current_user_can('manage_options') ) { // ONLY DO THIS FOR ADMIN
        if( $pagenow == 'index.php' ) {  // PRINTS ON DASHBOARD
            echo '<pre>'; print_r( $menu ); echo '</pre>'; // TOP LEVEL MENUS
            echo '<pre>'; print_r( $submenu ); echo '</pre>'; // SUBMENUS
        }
    }
}
add_action( 'admin_notices', 'debug_admin_menus' );
endif;

?>

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.