Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save FrancoStino/0de83a7e7483391730adc77b12645ed1 to your computer and use it in GitHub Desktop.
Save FrancoStino/0de83a7e7483391730adc77b12645ed1 to your computer and use it in GitHub Desktop.
Lets Shop Managers have the capability of editing and promoting users
<?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