equal
deleted
inserted
replaced
35 |
35 |
36 $this->meta = new WP_REST_User_Meta_Fields(); |
36 $this->meta = new WP_REST_User_Meta_Fields(); |
37 } |
37 } |
38 |
38 |
39 /** |
39 /** |
40 * Registers the routes for the objects of the controller. |
40 * Registers the routes for users. |
41 * |
41 * |
42 * @since 4.7.0 |
42 * @since 4.7.0 |
43 * |
43 * |
44 * @see register_rest_route() |
44 * @see register_rest_route() |
45 */ |
45 */ |
310 * @link https://developer.wordpress.org/reference/classes/wp_user_query/ |
310 * @link https://developer.wordpress.org/reference/classes/wp_user_query/ |
311 * |
311 * |
312 * @since 4.7.0 |
312 * @since 4.7.0 |
313 * |
313 * |
314 * @param array $prepared_args Array of arguments for WP_User_Query. |
314 * @param array $prepared_args Array of arguments for WP_User_Query. |
315 * @param WP_REST_Request $request The current request. |
315 * @param WP_REST_Request $request The REST API request. |
316 */ |
316 */ |
317 $prepared_args = apply_filters( 'rest_user_query', $prepared_args, $request ); |
317 $prepared_args = apply_filters( 'rest_user_query', $prepared_args, $request ); |
318 |
318 |
319 $query = new WP_User_Query( $prepared_args ); |
319 $query = new WP_User_Query( $prepared_args ); |
320 |
320 |
1071 /** |
1071 /** |
1072 * Prepares links for the user request. |
1072 * Prepares links for the user request. |
1073 * |
1073 * |
1074 * @since 4.7.0 |
1074 * @since 4.7.0 |
1075 * |
1075 * |
1076 * @param WP_Post $user User object. |
1076 * @param WP_User $user User object. |
1077 * @return array Links for the given user. |
1077 * @return array Links for the given user. |
1078 */ |
1078 */ |
1079 protected function prepare_links( $user ) { |
1079 protected function prepare_links( $user ) { |
1080 $links = array( |
1080 $links = array( |
1081 'self' => array( |
1081 'self' => array( |
1171 /** |
1171 /** |
1172 * Determines if the current user is allowed to make the desired roles change. |
1172 * Determines if the current user is allowed to make the desired roles change. |
1173 * |
1173 * |
1174 * @since 4.7.0 |
1174 * @since 4.7.0 |
1175 * |
1175 * |
1176 * @param integer $user_id User ID. |
1176 * @param int $user_id User ID. |
1177 * @param array $roles New user roles. |
1177 * @param array $roles New user roles. |
1178 * @return true|WP_Error True if the current user is allowed to make the role change, |
1178 * @return true|WP_Error True if the current user is allowed to make the role change, |
1179 * otherwise a WP_Error object. |
1179 * otherwise a WP_Error object. |
1180 */ |
1180 */ |
1181 protected function check_role_update( $user_id, $roles ) { |
1181 protected function check_role_update( $user_id, $roles ) { |
1182 global $wp_roles; |
1182 global $wp_roles; |
1289 } |
1289 } |
1290 |
1290 |
1291 if ( false !== strpos( $password, '\\' ) ) { |
1291 if ( false !== strpos( $password, '\\' ) ) { |
1292 return new WP_Error( |
1292 return new WP_Error( |
1293 'rest_user_invalid_password', |
1293 'rest_user_invalid_password', |
1294 __( 'Passwords cannot contain the "\\" character.' ), |
1294 sprintf( |
|
1295 /* translators: %s: The '\' character. */ |
|
1296 __( 'Passwords cannot contain the "%s" character.' ), |
|
1297 '\\' |
|
1298 ), |
1295 array( 'status' => 400 ) |
1299 array( 'status' => 400 ) |
1296 ); |
1300 ); |
1297 } |
1301 } |
1298 |
1302 |
1299 return $password; |
1303 return $password; |
1514 'type' => 'string', |
1518 'type' => 'string', |
1515 ); |
1519 ); |
1516 |
1520 |
1517 $query_params['orderby'] = array( |
1521 $query_params['orderby'] = array( |
1518 'default' => 'name', |
1522 'default' => 'name', |
1519 'description' => __( 'Sort collection by object attribute.' ), |
1523 'description' => __( 'Sort collection by user attribute.' ), |
1520 'enum' => array( |
1524 'enum' => array( |
1521 'id', |
1525 'id', |
1522 'include', |
1526 'include', |
1523 'name', |
1527 'name', |
1524 'registered_date', |
1528 'registered_date', |
1553 'authors', |
1557 'authors', |
1554 ), |
1558 ), |
1555 ); |
1559 ); |
1556 |
1560 |
1557 /** |
1561 /** |
1558 * Filter collection parameters for the users controller. |
1562 * Filters REST API collection parameters for the users controller. |
1559 * |
1563 * |
1560 * This filter registers the collection parameter, but does not map the |
1564 * This filter registers the collection parameter, but does not map the |
1561 * collection parameter to an internal WP_User_Query parameter. Use the |
1565 * collection parameter to an internal WP_User_Query parameter. Use the |
1562 * `rest_user_query` filter to set WP_User_Query arguments. |
1566 * `rest_user_query` filter to set WP_User_Query arguments. |
1563 * |
1567 * |