WP_REST_Users_Controller::prepare_links() WordPress Method

The WP_REST_Users_Controller::prepare_links() method is used to prepare links for the user data returned by the WP_REST_Controller::get_items() method. This method adds the self, collection, and up links to the user data.

WP_REST_Users_Controller::prepare_links( WP_User $user ) #

Prepares links for the user request.


Parameters

$user

(WP_User)(Required)User object.


Top ↑

Return

(array) Links for the given user.


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

	protected function prepare_links( $user ) {
		$links = array(
			'self'       => array(
				'href' => rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $user->ID ) ),
			),
			'collection' => array(
				'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ),
			),
		);

		return $links;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.