Changeset 60823 for branches/6.3/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
- Timestamp:
- 09/30/2025 05:01:27 PM (3 months ago)
- Location:
- branches/6.3
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/6.3
- Property svn:mergeinfo changed
/trunk merged: 60814-60816
- Property svn:mergeinfo changed
-
branches/6.3/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
r56840 r60823 211 211 return new WP_Error( 212 212 'rest_forbidden_context', 213 __( 'Sorry, you are not allowed to list users.' ),213 __( 'Sorry, you are not allowed to edit users.' ), 214 214 array( 'status' => rest_authorization_required_code() ) 215 215 ); … … 341 341 342 342 foreach ( $query->results as $user ) { 343 if ( 'edit' === $request['context'] && ! current_user_can( 'edit_user', $user->ID ) ) { 344 continue; 345 } 346 343 347 $data = $this->prepare_item_for_response( $user, $request ); 344 348 $users[] = $this->prepare_response_for_collection( $data ); … … 440 444 } 441 445 442 if ( 'edit' === $request['context'] && ! current_user_can( ' list_users') ) {443 return new WP_Error( 444 'rest_ user_cannot_view',445 __( 'Sorry, you are not allowed to list users.' ),446 if ( 'edit' === $request['context'] && ! current_user_can( 'edit_user', $user->ID ) ) { 447 return new WP_Error( 448 'rest_forbidden_context', 449 __( 'Sorry, you are not allowed to edit this user.' ), 446 450 array( 'status' => rest_authorization_required_code() ) 447 451 ); 448 } elseif ( ! count_user_posts( $user->ID, $types ) && ! current_user_can( 'edit_user', $user->ID ) && ! current_user_can( 'list_users' ) ) { 452 } 453 454 if ( ! current_user_can( 'edit_user', $user->ID ) && ! current_user_can( 'list_users' ) && ! count_user_posts( $user->ID, $types ) ) { 449 455 return new WP_Error( 450 456 'rest_user_cannot_view', … … 1040 1046 } 1041 1047 1042 if ( in_array( 'roles', $fields, true ) ) {1048 if ( in_array( 'roles', $fields, true ) && ( current_user_can( 'list_users' ) || current_user_can( 'edit_user', $user->ID ) ) ) { 1043 1049 // Defensively call array_values() to ensure an array is returned. 1044 1050 $data['roles'] = array_values( $user->roles );
Note: See TracChangeset
for help on using the changeset viewer.