I had the same error i did this piece of code and the status code will be force to be 200 in my case was when i was showing the user public profile.
function bbp_fix_users_404_headers() {
if (bp_displayed_user_id() != 0 && is_404() ) {
global $wp_query;
$wp_query->is_404 = false;
status_header( 200 );
}
}
add_action( 'wp', 'bbp_fix_users_404_headers',0 );
SOLVE
In the class class-wc-admin-php of Woocommerce there is a method called prevent_admin_access that validates the user permission, also there is a filter you can use to make your own logic.
woocommerce_prevent_admin_access
So in your theme functions.php or your custom plugin add next code.
add_filter('woocommerce_prevent_admin_access', 'check_admin_access');
function check_admin_access( $redirect_to ) {
$user = wp_get_current_user();
if( is_array( $user->roles ) && in_array( 'mycustomrol', $user->roles ) ) {
return false;
}
return true;
}
I worked for me.