LLMS_REST_Users_Controller::prepare_object_for_response( LLMS_Abstract_User_Data $object, WP_REST_Request $request )

Prepare an object for response


Parameters Parameters

$object

(LLMS_Abstract_User_Data) (Required) User object.

$request

(WP_REST_Request) (Required) Request object.


Top ↑

Return Return

(array)


Top ↑

Source Source

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

	/**
	 * Prepare an object for response
	 *
	 * @since 1.0.0-beta.1
	 * @since 1.0.0-beta.14 Only add remapped keys to the response when the schema key is present in the expected response fields array.
	 *
	 * @param LLMS_Abstract_User_Data $object  User object.
	 * @param WP_REST_Request         $request Request object.
	 * @return array
	 */
	protected function prepare_object_for_response( $object, $request ) {

		$prepared = array();
		$map      = array_flip( $this->map_schema_to_database() );
		$fields   = $this->get_fields_for_response( $request );

		// Write Only.
		unset( $map['user_pass'] );

		foreach ( $map as $db_key => $schema_key ) {
			if ( in_array( $schema_key, $fields, true ) ) {
				$prepared[ $schema_key ] = $object->get( $db_key );
			}
		}



Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.14 Only add remapped keys to the response when the schema key is present in the expected response fields array.
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.