Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Caseproof

    (@caseproof)

    Hi @dwnl

    If you want to block a specific admin menu item, you can try this code:

    add_action( 'admin_menu', 'members_remove_menu_pages' );
    function members_remove_menu_pages() {
      $user = wp_get_current_user();
      if ( in_array('subscriber', $user->roles) ) {
        remove_menu_page('users.php');
      }
    }

    and replace ‘users.php’ part with your menu item.

    Regarding hiding WooCommerce admin bar, have you tried to add this code that should prevent any user who cannot ‘edit_posts’ (subscribers, customers, etc) from seeing the admin bar:

    function wc_disable_admin_bar( $show_admin_bar ) {
       if ( apply_filters( 'woocommerce_disable_admin_bar', get_option( 'woocommerce_lock_down_admin', 'yes' ) === 'yes' ) && ! ( current_user_can( 'edit_posts' ) || current_user_can( 'manage_woocommerce' ) ) ) {
          $show_admin_bar = false;
       }
     
       return $show_admin_bar;
    }
    add_filter( 'show_admin_bar', 'wc_disable_admin_bar', 10, 1 );

    Kind regards

    Thread Starter SLV

    (@dwnl)

    Hello,

    sorry it is not clear to me what I must put in instead of the users.php… for this plugin: https://nl.wordpress.org/plugins/yith-woocommerce-badges-management/ : Can’t find it to reject in your plugin.

    <div class=”wp-menu-name”>Badges</div>

    Also, how do I hide the +New icon in de adminbar ?
    <li id=”wp-admin-bar-new-content” class=”menupop”>

    Your code for hiding the admin bar breaks my shop… So that one doesn’t work…

    • This reply was modified 2 years, 6 months ago by SLV.
    • This reply was modified 2 years, 6 months ago by SLV.
    • This reply was modified 2 years, 6 months ago by SLV.
    Thread Starter SLV

    (@dwnl)

    • This reply was modified 2 years, 6 months ago by SLV.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide 3 plugin menu items’ is closed to new replies.