Last active
January 10, 2017 21:51
-
-
Save Abd-Ur-Rehman/5c581b97baff8e8cce0fb8e85a03cc9c to your computer and use it in GitHub Desktop.
View full post at http://www.abdurrehman.net/blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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