woocommerce_shop_manager_editable_roles

woocommerce_shop_manager_editable_roles

Appears in: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Hook Type: filter

See hook in core

Displaying hooks found in version: woocommerce.9.8.1

apply_filters('woocommerce_shop_manager_editable_roles') is found 3 times:

  • /includes/wc-rest-functions.php line 268

    // Check to allow shop_managers to manage only customers.
    if ( in_array( $context, array( ‘edit’, ‘delete’ ), true ) && wc_current_user_has_role( ‘shop_manager’ ) ) {
    $permission = false;
    $user_data = get_userdata( $object_id );
    $shop_manager_editable_roles = apply_filters( ‘woocommerce_shop_manager_editable_roles’, array( ‘customer’ ) );

    if ( isset( $user_data->roles ) ) {
    $can_manage_users = array_intersect( $user_data->roles, array_unique( $shop_manager_editable_roles ) );

    // Check if Shop Manager can edit customer or with the is same shop manager.
    if ( 0 < count( $can_manage_users ) || intval( $object_id ) === intval( get_current_user_id() ) ) { [/php]

  • /includes/wc-user-functions.php line 678
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
        if ( ! wc_current_user_has_role( 'administrator' ) ) {
            unset( $roles['administrator'] );
     
            if ( wc_current_user_has_role( 'shop_manager' ) ) {
                $shop_manager_editable_roles = apply_filters( 'woocommerce_shop_manager_editable_roles', array( 'customer' ) );
                return array_intersect_key( $roles, array_flip( $shop_manager_editable_roles ) );
            }
        }
     
        return $roles;
    }
  • /includes/wc-user-functions.php line 715
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
            $caps[] = 'do_not_allow';
        } elseif ( wc_current_user_has_role( 'shop_manager' ) ) {
            // Shop managers can only edit customer info.
            $userdata                    = get_userdata( $args[0] );
            $shop_manager_editable_roles = apply_filters( 'woocommerce_shop_manager_editable_roles', array( 'customer' ) ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
            if ( property_exists( $userdata, 'roles' ) && ! empty( $userdata->roles ) && ! array_intersect( $userdata->roles, $shop_manager_editable_roles ) ) {
                $caps[] = 'do_not_allow';
            }
        }
    }
    break;