wc_disable_admin_bar()
Prevent any user who cannot 'edit_posts' (subscribers, customers etc) from seeing the admin bar.
Note: get_option( 'woocommerce_lock_down_admin', true ) is a deprecated option here for backwards compatibility. Defaults to true.
Hooks from the function
Return
true|false
.
Usage
wc_disable_admin_bar( $show_admin_bar );
- $show_admin_bar(true|false) (required)
- If should display admin bar.
wc_disable_admin_bar() wc disable admin bar code WC 9.4.2
function wc_disable_admin_bar( $show_admin_bar ) { /** * Controls whether the WooCommerce admin bar should be disabled. * * @since 3.0.0 * * @param bool $enabled */ if ( apply_filters( 'woocommerce_disable_admin_bar', true ) && ! ( current_user_can( 'edit_posts' ) || current_user_can( 'manage_woocommerce' ) ) ) { $show_admin_bar = false; } return $show_admin_bar; }