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.
Return Return
(array)
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 ); } }
Expand full source code Collapse full source code View on GitHub
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. |