- Timestamp:
- 04/25/2018 01:05:48 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
r42761 r43001 193 193 } 194 194 195 if ( 'authors' === $request['who'] ) { 196 $can_view = false; 197 $types = get_post_types( array( 'show_in_rest' => true ), 'objects' ); 198 foreach ( $types as $type ) { 199 if ( current_user_can( $type->cap->edit_posts ) ) { 200 $can_view = true; 201 } 202 } 203 if ( ! $can_view ) { 204 return new WP_Error( 'rest_forbidden_who', __( 'Sorry, you are not allowed to query users by this parameter.' ), array( 'status' => rest_authorization_required_code() ) ); 205 } 206 } 207 195 208 return true; 196 209 } … … 257 270 } 258 271 259 if ( ! current_user_can( 'list_users' ) ) { 272 if ( isset( $registered['who'] ) && ! empty( $request['who'] ) && 'authors' === $request['who'] ) { 273 $prepared_args['who'] = 'authors'; 274 } elseif ( ! current_user_can( 'list_users' ) ) { 260 275 $prepared_args['has_published_posts'] = get_post_types( array( 'show_in_rest' => true ), 'names' ); 261 276 } … … 1373 1388 ); 1374 1389 1390 $query_params['who'] = array( 1391 'description' => __( 'Limit result set to users who are considered authors.' ), 1392 'type' => 'string', 1393 'enum' => array( 1394 'authors', 1395 ), 1396 ); 1397 1375 1398 /** 1376 1399 * Filter collection parameters for the users controller.
Note: See TracChangeset
for help on using the changeset viewer.