WooCommerce has a special "account page" that customers get re-directed to instead of the WordPress admin backend. I'm trying to create a custom role that does NOT go to that page. When I clone "subscriber", it goes to the Woo account page. When I clone "administrator" it goes to the WP backend. Which set or specific capability is handling this?
1 Answer
WooCommerce will only show the admin bar and give dashboard access to users who have the edit_posts
or manage_woocommerce
capabilities. If you don't want to give users one of those capabilities, you can use the woocommerce_disable_admin_bar
filter to give access and show the admin bar:
add_filter(
'woocommerce_disable_admin_bar',
function( $disable_admin_bar ) {
if ( current_user_can( 'my_capability' ) ) {
$disable_admin_bar = false;
}
return $disable_admin_bar;
}
);
Despite the name that will also give access to the dashboard, in addition to showing the admin bar.
If you only want to give dashboard access without displaying the admin bar, you can use the woocommerce_prevent_admin_access
filter, which works exactly the same way, or you can give the user/role the view_admin_dashboard
capability.