LLMS_REST_Users_Controller::get_objects_query( array $prepared, WP_REST_Request $request )

Retrieve a query object based on arguments from a get_items() (collection) request


Parameters Parameters

$prepared

(array) (Required) Array of collection arguments.

$request

(WP_REST_Request) (Required) Request object.


Top ↑

Return Return

(WP_User_Query)


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/abstracts/class-llms-rest-users-controller.php

	/**
	 * Retrieve a query object based on arguments from a `get_items()` (collection) request
	 *
	 * @since 1.0.0-beta.1
	 * @since 1.0.0-beta.12 Parse `search` and `search_columns` args.
	 *
	 * @param array           $prepared Array of collection arguments.
	 * @param WP_REST_Request $request  Request object.
	 * @return WP_User_Query
	 */
	protected function get_objects_query( $prepared, $request ) {

		if ( 'id' === $prepared['orderby'] ) {
			$prepared['orderby'] = 'ID';
		} elseif ( 'registered_date' === $prepared['orderby'] ) {
			$prepared['orderby'] = 'registered';
		}

		$args = array(
			'paged'   => $prepared['page'],
			'number'  => $prepared['per_page'],
			'order'   => strtoupper( $prepared['order'] ),
			'orderby' => $prepared['orderby'],
		);

		if ( ! empty( $prepared['roles'] ) ) {
			$args['role__in'] = $prepared['roles'];
		}

		if ( ! empty( $prepared['include'] ) ) {
			$args['include'] = $prepared['include'];
		}

		if ( ! empty( $prepared['exclude'] ) ) {
			$args['exclude'] = $prepared['exclude'];
		}



Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.12 Parse search and search_columns args.
1.0.0-beta.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.