Skip to content
Docs
Get RestroPress

Filter

rest_rp_customer_item_schema

Updated
On this page

Filters the JSON schema of a customer in the REST API.

Applied when the customer controller builds its item schema. Add or change properties to expose extra customer data. The result is stored on the controller and extended with registered additional fields.

Parameters#

ParameterTypeDescription
$schemaarrayThe JSON schema definition for the customer.

Return value#

array. The schema.

Example#

function my_customer_schema( $schema ) {
	$schema['properties']['loyalty_tier'] = array(
		'description' => __( 'Loyalty tier.', 'my-textdomain' ),
		'type'        => 'string',
		'context'     => array( 'view' ),
		'readonly'    => true,
	);
	return $schema;
}
add_filter( 'rest_rp_customer_item_schema', 'my_customer_schema' );

Source#

Applied in:

  • includes/rest-api/Controllers/Version1/class-rp-rest-customer-v1-controller.php (line 380), in RP_REST_Customer_v1_Controller::get_item_schema()

See also#

Was this page helpful?