public function update_item_permissions_check($request)
{
$id = (int) $request['id'];
if (!current_user_can('edit_user', $id)) {
return new WP_Error('rest_cannot_edit', __('Sorry, you are not allowed to edit this user.'), array('status' => rest_authorization_required_code()));
}
if (!empty($request['roles']) && !current_user_can('edit_users')) {
return new WP_Error('rest_cannot_edit_roles', __('Sorry, you are not allowed to edit roles of this user.'), array('status' => rest_authorization_required_code()));
}
return true;
}