Skip to content

Instantly share code, notes, and snippets.

@Abd-Ur-Rehman
Last active January 10, 2017 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Abd-Ur-Rehman/5c581b97baff8e8cce0fb8e85a03cc9c to your computer and use it in GitHub Desktop.
Save Abd-Ur-Rehman/5c581b97baff8e8cce0fb8e85a03cc9c to your computer and use it in GitHub Desktop.
/**
* 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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment