REST API: Allow fetching multiple users at once via the slug parameter.

This matches similar changes previously made for posts (#38579) and terms (#40027).

Props curdin, MatheusGimenez.
Fixes #40213.

Built from https://develop.svn.wordpress.org/trunk@40378


git-svn-id: http://core.svn.wordpress.org/trunk@40285 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
James Nylen 2017-04-05 22:25:43 +00:00
parent 1979815aef
commit 99b13790c2
2 changed files with 7 additions and 9 deletions

View File

@ -221,6 +221,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
'per_page' => 'number',
'search' => 'search',
'roles' => 'role__in',
'slug' => 'nicename__in',
);
$prepared_args = array();
@ -261,12 +262,6 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
if ( ! empty( $prepared_args['search'] ) ) {
$prepared_args['search'] = '*' . $prepared_args['search'] . '*';
}
if ( isset( $registered['slug'] ) && ! empty( $request['slug'] ) ) {
$prepared_args['search'] = $request['slug'];
$prepared_args['search_columns'] = array( 'user_nicename' );
}
/**
* Filters WP_User_Query arguments when querying users via the REST API.
*
@ -1363,8 +1358,11 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
);
$query_params['slug'] = array(
'description' => __( 'Limit result set to users with a specific slug.' ),
'type' => 'string',
'description' => __( 'Limit result set to users with one or more specific slugs.' ),
'type' => 'array',
'items' => array(
'type' => 'string',
),
);
$query_params['roles'] = array(

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.8-alpha-40377';
$wp_version = '4.8-alpha-40378';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.