Php code to allow Super Admin to override.

Hi.

Could you help with a piece of code that allows Super Admin to override this code, please:-

function remove_menus(){

remove_menu_page( ‘index.php’ ); //Dashboard

/*remove_menu_page( ‘jetpack’ );*/ //Jetpack

remove_menu_page( ‘edit.php’ ); //Posts

remove_menu_page( ‘upload.php’ ); //Media

/*remove_menu_page( ‘edit.php?post_type=page’ );*/ //Pages

remove_menu_page( ‘edit-comments.php’ ); //Comments

remove_menu_page( ‘themes.php’ ); //Appearance

remove_menu_page( ‘plugins.php’ ); //Plugins

remove_menu_page( ‘users.php’ ); //Users

remove_menu_page( ‘tools.php’ ); //Tools

remove_menu_page( ‘options-general.php’ ); //Settings

add_action( ‘admin_menu’, ‘my_remove_menus’, 999 );

function my_remove_menus() {

remove_submenu_page( ‘themes.php’, ‘theme-editor.php’ );

}

}

add_action( ‘admin_menu’, ‘remove_menus’ );

………………..This removes selected items in the Admin Panel.

Thanking you in advance.

Regards

johnv

  • Rupok
    • Ex Staff

    Hi johnv,

    You can add action based on user role. Can you try the following code instead of your one?

    function remove_menus(){

    remove_menu_page( 'index.php' ); //Dashboard
    /*remove_menu_page( 'jetpack' );*/ //Jetpack
    remove_menu_page( 'edit.php' ); //Posts
    remove_menu_page( 'upload.php' ); //Media
    /*remove_menu_page( 'edit.php?post_type=page' );*/ //Pages
    remove_menu_page( 'edit-comments.php' ); //Comments
    remove_menu_page( 'themes.php' ); //Appearance
    remove_menu_page( 'plugins.php' ); //Plugins
    remove_menu_page( 'users.php' ); //Users
    remove_menu_page( 'tools.php' ); //Tools
    remove_menu_page( 'options-general.php' ); //Settings

    add_action( 'admin_menu', 'my_remove_menus', 999 );

    function my_remove_menus() {
    remove_submenu_page( 'themes.php', 'theme-editor.php' );
    }

    }

    if ( !is_super_admin() ) {
    add_action( 'admin_menu', 'remove_menus' );
    }

    Please let us know if this doesn’t work or if this is not what you are looking for. We will be very glad to help further.

    Have a nice day. Cheers!

    Rupok