Last active
January 12, 2022 12:44
-
-
Save Yiannistaos/b06885faad53a6be4675450c9fab4054 to your computer and use it in GitHub Desktop.
The Login as User WordPress Plugin is now compatible with the Wholesale Suite WordPress Plugin
This file contains 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 | |
/** | |
* BEGIN: Web357 Login as User WordPress Plugin | |
* The Login as User WordPress Plugin is now compatible with the Wholesale Suite WordPress Plugin | |
* Allow shop managers to Login as Wholesale Customer | |
* Add the code below in the functions.php of your current theme | |
*/ | |
/* Lets Shop Managers have the capability of editing and promoting users */ | |
add_action( 'admin_init', 'wws_add_shop_manager_user_editing_capability'); | |
function wws_add_shop_manager_user_editing_capability() { | |
$shop_manager = get_role( 'shop_manager' ); | |
$shop_manager->add_cap( 'edit_users' ); | |
$shop_manager->add_cap( 'edit_user' ); | |
$shop_manager->add_cap( 'promote_users' ); | |
} | |
/* Lets Shop Managers edit users with these user roles */ | |
add_filter( 'woocommerce_shop_manager_editable_roles', 'wws_allow_shop_manager_role_edit_capabilities' ); | |
function wws_allow_shop_manager_role_edit_capabilities( $roles ) { | |
$roles[] = 'wholesale_customer'; // insert the wholesale role here, copy+paste this line for additional user roles | |
return $roles; | |
} | |
/** | |
* END: Web357 Login as User WordPress Plugin | |
*/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment