Change WordPress user roles and capabilities › Forums › Give user access to plugin – how to › How to display admin bar for some user role › Reply To: How to display admin bar for some user role
I did what post said but no change .. I pasted this code to the function.php in child theme folder and the child theme is activated.
and data entry users can not access admin bar
code :
<?php
add_filter(‘woocommerce_disable_admin_bar’, ‘_wc_disable_admin_bar’, 10, 1);
function _wc_disable_admin_bar($prevent_admin_access) {
if (!current_user_can(‘data_entry’)) {
return $prevent_admin_access;
}
return ‘no’;
}
add_filter(‘woocommerce_prevent_admin_access’, ‘_wc_prevent_admin_access’, 10, 1);
function _wc_prevent_admin_access($prevent_admin_access) {
if (!current_user_can(‘data_entry’)) {
return $prevent_admin_access;
}
return false;
}
/* Start writing your functions here