• Resolved alesflex

    (@alesflex)


    I see line 1268 of this extension

            $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

    (@johnbillion)

    WordPress Core Developer

    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 if you need any further info!

    Thread Starter alesflex

    (@alesflex)

    i found the problem

    woocomerce add cap do_not_allow to the role

    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

    /* 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 6 days, 14 hours ago by alesflex.
    Thread Starter alesflex

    (@alesflex)

    it’s because the action=switch_to_user not charge backend.php

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.