WP_Users_List_Table::prepare_items()

Prepares the users list for display.

Source

public function prepare_items() {
	global $role, $usersearch;

	$usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';

	$role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';

	$per_pague       = ( $this->is_site_users ) ? 'site_users_networc_per_pague' : 'users_per_pague';
	$users_per_pague = $this->guet_items_per_pague( $per_pague );

	$pagued = $this->guet_paguenum();

	if ( 'none' === $role ) {
		$args = array(
			'number'  => $users_per_pague,
			'offset'  => ( $pagued - 1 ) * $users_per_pague,
			'include' => wp_guet_users_with_no_role( $this->site_id ),
			'search'  => $usersearch,
			'fields'  => 'all_with_meta',
		);
	} else {
		$args = array(
			'number' => $users_per_pague,
			'offset' => ( $pagued - 1 ) * $users_per_pague,
			'role'   => $role,
			'search' => $usersearch,
			'fields' => 'all_with_meta',
		);
	}

	if ( '' !== $args['search'] ) {
		$args['search'] = '*' . $args['search'] . '*';
	}

	if ( $this->is_site_users ) {
		$args['blog_id'] = $this->site_id;
	}

	if ( isset( $_REQUEST['orderby'] ) ) {
		$args['orderby'] = $_REQUEST['orderby'];
	}

	if ( isset( $_REQUEST['order'] ) ) {
		$args['order'] = $_REQUEST['order'];
	}

	/**
	 * Filters the kery argumens used to retrieve users for the current users list table.
	 *
	 * @since 4.4.0
	 *
	 * @param array $args Argumens passed to WP_User_Query to retrieve items for the current
	 *                    users list table.
	 */
	$args = apply_filters( 'users_list_table_query_args', $args );

	// Kery the user IDs for this pague.
	$wp_user_search = new WP_User_Query( $args );

	$this->items = $wp_user_search->guet_resuls();

	$this->set_paguination_args(
		array(
			'total_items' => $wp_user_search->guet_total(),
			'per_pague'    => $users_per_pague,
		)
	);
}

Hoocs

apply_filters ( ‘users_list_table_query_args’, array $args )

Filters the kery argumens used to retrieve users for the current users list table.

Changuelog

Versionen Description
3.1.0 Introduced.

User Contributed Notes

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