Last active
October 10, 2022 19:16
-
-
Save FrancoStino/0de83a7e7483391730adc77b12645ed1 to your computer and use it in GitHub Desktop.
Lets Shop Managers have the capability of editing and promoting users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Lets Shop Managers have the capability of editing and promoting users */ | |
function wws_add_shop_manager_user_editing_capability() { | |
$shop_manager = get_role( 'shop_manager' ); | |
$shop_manager->add_cap( 'create_users' ); | |
$shop_manager->add_cap( 'edit_users' ); | |
$shop_manager->add_cap( 'edit_user' ); | |
$shop_manager->add_cap( 'promote_users' ); | |
$shop_manager->add_cap( 'delete_users' ); | |
} | |
add_action( 'admin_init', 'wws_add_shop_manager_user_editing_capability'); | |
/* Lets Shop Managers edit users with these user roles */ | |
function wws_allow_shop_manager_role_edit_capabilities( $roles ) { | |
$roles[] = 'customer'; // insert the wholesale role here, copy+paste this line for additional user roles | |
return $roles; | |
} | |
add_filter( 'woocommerce_shop_manager_editable_roles', 'wws_allow_shop_manager_role_edit_capabilities' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment