• Hi I need to hide this from the admin menu for any user that is not an administrator, please could you provide some code for this or add it as an option to the settings? It does not provide useful functionality to editors and contributors but it does clutter up the interface and make it more challenging to approach/use for novices.

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • I came here today looking for this exact solution. I had a customer who is a “shop manager” on the site (with WooCommerce) and was bugging me about “what is this activity log thing that I can’t access?” They think the site is broken.

    I wish NOT to use a plugin for this, but rather hard code it in child theme or custom functions.

    Thread Starter vision-hive

    (@vision-hive)

    I ended up using this function:

    // Remove tools & activity log metabox from dashboard for <= editors
    function TRIM_ADMIN_MENU() {
        global $current_user;
        if(!current_user_can('administrator')) {
            remove_menu_page( 'tools.php' ); // No tools for <= editors
            @remove_menu_page( 'activity_log_page' ); // Activity log
        }
    }
    add_action('admin_init', 'TRIM_ADMIN_MENU');

    There is a plugin that you can hide whatever you want from the admin bar according to the user_role.
    It is very useful if you want to hide other menu_items for non-admin users.
    Plugin: https://wordpress.org/plugins/remove-admin-menus-by-role/

    @vision-hive,
    thank you for the useful function.
    I prefer to use functions as well, better than activate a lot of plugins.

    What if you have 2 admins and you want to hide a menu item from one of the admins – that snippet is no use for this scenario

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to hide this for non-admins?’ is closed to new replies.