This is likely due to your theme or a plugin managing the roles visible in the new user screen. An attempt at security gone awry perhaps.
To see all the roles that are supposed to be available, temporarily add this code to a template, such as page.php (into a HTML portion, not a PHP portion):
<pre><?php
print_r( wp_roles()->roles );
?></pre>
View a page that uses the template. You should see shop manager et al roles listed. If you see only customer, there is a deeper problem.
Assuming you see the other roles, deactivate all plugins. WC roles will persist even if WC is inactive. Flush your browser cache. Check the new user screen, you should see all the usual roles again. If not, your theme is managing what is visible. Restore your plugins, one at a time. When the roles available are again restricted, the last activated plugin is causing the problem.
Thanks @bcworkz.
I did the plugin check and it looks like WooCommerce is the one causing the trouble. Oddly, it’s only when it’s activated on the main site, but it’s fine if it’s activated on the other sites in the network.
Well that’s unexpected! You could try seeking resolution through the dedicated WC forum.
Plugins normally use the ‘editable_roles’ filter to intentionally alter what roles we can select on the new user screen. A place to start if you want to investigate for yourself. But if the missing roles are not intentional, it probably wouldn’t lead anywhere. More likely the global $wp_roles has been manipulated.
@spencerfcloud
Did you find any solution as same problem is showing in my site
Hi all, Please check the solution below @correyjames @spencerfcloud @bcworkz
File Path : \wp-content\plugins\woocommerce\includes\wc-user-functions.php
Function Name: wc_modify_editable_roles
============================================================
Code Before Changes:
function wc_modify_editable_roles( $roles ) {
if ( ! current_user_can( 'administrator' ) ) {
unset( $roles['administrator'] );
}
if ( current_user_can( 'shop_manager' ) ) {
$shop_manager_editable_roles = apply_filters( 'woocommerce_shop_manager_editable_roles', array( 'customer' ) );
return array_intersect_key( $roles, array_flip( $shop_manager_editable_roles ) );
}
return $roles;
}
add_filter( 'editable_roles', 'wc_modify_editable_roles' );
===============================================================
Code After Changes:
function wc_modify_editable_roles( $roles ) {
if ( ! current_user_can( 'administrator' ) ) {
unset( $roles['administrator'] );
if ( current_user_can( 'shop_manager' ) ) {
$shop_manager_editable_roles = apply_filters( 'woocommerce_shop_manager_editable_roles', array( 'customer' ) );
return array_intersect_key( $roles, array_flip( $shop_manager_editable_roles ) );
}
}
return $roles;
}
add_filter( 'editable_roles', 'wc_modify_editable_roles' );
@correyjames
Actually the most recent update of WooCommerce seems to have fixed it.
@01radteam
Thanks for the solution! The most recent update of WooCommerce seems to have fixed it on my site, but if I run into the issue again I’ll be sure to come back here.