Change WordPress user roles and capabilities › Forums › How to or FAQ › Settings to show WP admin Bar on Front End › Reply To: Settings to show WP admin Bar on Front End
20/02/2020 at 06:17
#6642
Vladimir
Keymaster
Yes, I missed a closing bracket at the line 8. Valid code is:
add_filter( 'woocommerce_disable_admin_bar', '_wc_disable_admin_bar', 10, 1 );
function _wc_disable_admin_bar( $disable ) {
$user = wp_get_current_user();
if ( !is_a( $user, 'WP_User') || !is_array( $user->roles ) ) {
return $disable;
}
if ( !in_array( 'membership_manager', $user->roles ) ) {
return $disable;
}
return false;
}
If filter does not help I suppose that another plugin may have own setting for showing admin bar at the front-end.
Try to add ‘manage_woocommerce’ to membership_manager role to exclude WooCommerce. Will it help? If it did not help, try to deactivate all plugins and re-test activating them back one by one, to isolate a source of the problem.