wc_disable_admin_bar

Prevent any user who cannot 'edit_posts' (subscribers, customers etc) from seeing the admin bar.

Description

wc_disable_admin_bar( (bool) $show_admin_bar ); 

Note: get_option( woocommerce_lock_down_admin,, true ) is a deprecated option here for backwards compat. Defaults to true.

Parameters (1)

0. $show_admin_bar (bool)
The show admin bar.

Usage

  1. if ( !function_exists( 'wc_disable_admin_bar' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-user-functions.php'; 
  3.  
  4. // The show admin bar. 
  5. $show_admin_bar = true; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_disable_admin_bar($show_admin_bar); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-user-functions.php  
  1. function wc_disable_admin_bar( $show_admin_bar ) { 
  2. 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' ) ) ) { 
  3. $show_admin_bar = false; 
  4.  
  5. return $show_admin_bar;