WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_User_Query::query() WP 3.1.0

Execute the query, with the current variables.

Это метод класса: WP_User_Query

Хуки из метода
Возвращает

Null. Ничего.

Использование

$WP_User_Query = new WP_User_Query();
$var = $WP_User_Query->query();

Заметки

  • Global. wpdb. $wpdb WordPress database abstraction object.

Список изменений

С версии 3.1.0 Введена.

Код WP User Query::query: wp-includes/class-wp-user-query.php WP 5.3.1

<?php
public function query() {
	global $wpdb;

	$qv =& $this->query_vars;

	/**
	 * Filters the users array before the query takes place.
	 *
	 * Return a non-null value to bypass WordPress's default user queries.
	 * Filtering functions that require pagination information are encouraged to set
	 * the `total_users` property of the WP_User_Query object, passed to the filter
	 * by reference. If WP_User_Query does not perform a database query, it will not
	 * have enough information to generate these values itself.
	 *
	 * @since 5.1.0
	 *
	 * @param array|null $results Return an array of user data to short-circuit WP's user query
	 *                            or null to allow WP to run its normal queries.
	 * @param WP_User_Query $this The WP_User_Query instance (passed by reference).
	 */
	$this->results = apply_filters_ref_array( 'users_pre_query', array( null, &$this ) );

	if ( null === $this->results ) {
		$this->request = "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit";

		if ( is_array( $qv['fields'] ) || 'all' == $qv['fields'] ) {
			$this->results = $wpdb->get_results( $this->request );
		} else {
			$this->results = $wpdb->get_col( $this->request );
		}

		if ( isset( $qv['count_total'] ) && $qv['count_total'] ) {
			/**
			 * Filters SELECT FOUND_ROWS() query for the current WP_User_Query instance.
			 *
			 * @since 3.2.0
			 * @since 5.1.0 Added the `$this` parameter.
			 *
			 * @global wpdb $wpdb WordPress database abstraction object.
			 *
			 * @param string $sql         The SELECT FOUND_ROWS() query for the current WP_User_Query.
			 * @param WP_User_Query $this The current WP_User_Query instance.
			 */
			$found_users_query = apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()', $this );

			$this->total_users = (int) $wpdb->get_var( $found_users_query );
		}
	}

	if ( ! $this->results ) {
		return;
	}

	if ( 'all_with_meta' == $qv['fields'] ) {
		cache_users( $this->results );

		$r = array();
		foreach ( $this->results as $userid ) {
			$r[ $userid ] = new WP_User( $userid, '', $qv['blog_id'] );
		}

		$this->results = $r;
	} elseif ( 'all' == $qv['fields'] ) {
		foreach ( $this->results as $key => $user ) {
			$this->results[ $key ] = new WP_User( $user, '', $qv['blog_id'] );
		}
	}
}