Title: capabilities edit_users vs edit_user
Last modified: March 18, 2025

---

# capabilities edit_users vs edit_user

 *  Resolved [alesflex](https://wordpress.org/support/users/alesflex/)
 * (@alesflex)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/capabilities-edit_users-vs-edit_user/)
 * I see line 1268 of this extension
 *     ```wp-block-code
               $user_caps['switch_to_user'] = ( user_can( $user->ID, 'edit_user', $args[2] ) && ( $args[2] !== $user->ID ) );
       ```
   
 * I dont know why but for a specific role is work for generate the link to switch
   but not to really switch
 * current_user_can( ‘switch_to_user’, $user_id ) is true in users list page but
   false when action=switch_to_user.
 * I think the test user_can have to look to capabilitie ‘edit_users’ and not ‘edit_user’.
 * If i change that it’s work.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [John Blackbourn](https://wordpress.org/support/users/johnbillion/)
 * (@johnbillion)
 * WordPress Core Developer
 * [1 year, 3 months ago](https://wordpress.org/support/topic/capabilities-edit_users-vs-edit_user/#post-18367934)
 * `edit_user` is a meta capability which usually maps to `edit_users` after any
   additional logic is performed. I can’t help you with the issue on your site, 
   but you should check any other plugins on your site that might be making adjustments
   to user roles or capabilities.
 * Take a read through [the FAQ](https://wordpress.org/plugins/user-switching/#faq)
   if you need any further info!
 *  Thread Starter [alesflex](https://wordpress.org/support/users/alesflex/)
 * (@alesflex)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/capabilities-edit_users-vs-edit_user/#post-18368265)
 * i found the problem
 * woocomerce add cap do_not_allow to the role
 *     ```wp-block-code
       if ( property_exists( $userdata, 'roles' ) && ! empty( $userdata->roles ) && ! array_intersect( $userdata->roles, $shop_manager_editable_roles ) ) {							$caps[] = 'do_not_allow';						}
       ```
   
 * Because in backend.php i add restaurant to editable role
 *     ```wp-block-code
       /* Lets Shop Managers edit users with these user roles */function wws_allow_shop_manager_role_edit_capabilities( $roles ) {    $roles[] = 'restaurant'; // 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' );
       ```
   
 * if i add it in function.php the role it’s editable and switchable
    -  This reply was modified 1 year, 3 months ago by [alesflex](https://wordpress.org/support/users/alesflex/).
 *  Thread Starter [alesflex](https://wordpress.org/support/users/alesflex/)
 * (@alesflex)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/capabilities-edit_users-vs-edit_user/#post-18368293)
 * it’s because the action=switch_to_user not charge backend.php

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘capabilities edit_users vs edit_user’ is closed to new replies.

 * ![](https://ps.w.org/user-switching/assets/icon.svg?rev=3193956)
 * [User Switching](https://wordpress.org/plugins/user-switching/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/user-switching/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/user-switching/)
 * [Active Topics](https://wordpress.org/support/plugin/user-switching/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/user-switching/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/user-switching/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [alesflex](https://wordpress.org/support/users/alesflex/)
 * Last activity: [1 year, 3 months ago](https://wordpress.org/support/topic/capabilities-edit_users-vs-edit_user/#post-18368293)
 * Status: resolved