BP_REST_XProfile_Fields_Endpoint::get_item_schema()

Get the XProfile field schema, conforming to JSON Schema.

Description

Return

(array)

Source

File: bp-xprofile/classes/class-bp-rest-xprofile-fields-endpoint.php

	public function get_item_schema() {
		$schema = array(
			'$schema'    => 'http://json-schema.org/draft-04/schema#',
			'title'      => 'bp_xprofile_field',
			'type'       => 'object',
			'properties' => array(
				'id'                => array(
					'context'     => array( 'embed', 'view', 'edit' ),
					'description' => __( 'A unique numeric ID for the profile field.', 'buddyboss' ),
					'readonly'    => true,
					'type'        => 'integer',
				),
				'group_id'          => array(
					'context'     => array( 'embed', 'view', 'edit' ),
					'description' => __( 'The ID of the group the field is part of.', 'buddyboss' ),
					'type'        => 'integer',
				),
				'parent_id'         => array(
					'context'     => array( 'embed', 'view', 'edit' ),
					'description' => __( 'The ID of the parent field.', 'buddyboss' ),
					'type'        => 'integer',
				),
				'type'              => array(
					'context'     => array( 'embed', 'view', 'edit' ),
					'description' => __( 'The type for the profile field.', 'buddyboss' ),
					'type'        => 'string',
					'enum'        => buddypress()->profile->field_types,
					'arg_options' => array(
						'sanitize_callback' => 'sanitize_key',
					),
				),
				'name'              => array(
					'context'     => array( 'embed', 'view', 'edit' ),
					'description' => __( 'The name of the profile field.', 'buddyboss' ),
					'type'        => 'string',
					'arg_options' => array(
						'sanitize_callback' => 'sanitize_text_field',
					),
				),
				'alternate_name'    => array(
					'context'     => array( 'embed', 'view', 'edit' ),
					'description' => __( 'The alternate name of the profile field.', 'buddyboss' ),
					'type'        => 'string',
					'default'     => '',
					'arg_options' => array(
						'sanitize_callback' => 'sanitize_text_field',
					),
				),
				'description'       => array(
					'context'     => array( 'embed', 'view', 'edit' ),
					'description' => __( 'The description of the profile field.', 'buddyboss' ),
					'type'        => 'object',
					'arg_options' => array(
						'sanitize_callback' => null,
						// Note: sanitization implemented in self::prepare_item_for_database().
						'validate_callback' => null,
						// Note: validation implemented in self::prepare_item_for_database().
					),
					'properties'  => array(
						'raw'      => array(
							'description' => __( 'Content for the profile field, as it exists in the database.', 'buddyboss' ),
							'type'        => 'string',
							'context'     => array( 'edit' ),
						),
						'rendered' => array(
							'description' => __( 'HTML content for the profile field, transformed for display.', 'buddyboss' ),
							'type'        => 'string',
							'context'     => array( 'embed', 'view', 'edit' ),
							'readonly'    => true,
						),
					),
				),
				'is_required'       => array(
					'context'     => array( 'embed', 'view', 'edit' ),
					'description' => __( 'Whether the profile field must have a value.', 'buddyboss' ),
					'type'        => 'boolean',
				),
				'can_delete'        => array(
					'context'     => array( 'embed', 'view', 'edit' ),
					'description' => __( 'Whether the profile field can be deleted or not.', 'buddyboss' ),
					'default'     => true,
					'type'        => 'boolean',
				),
				'field_order'       => array(
					'context'     => array( 'embed', 'view', 'edit' ),
					'description' => __( 'The order of the profile field into the group of fields.', 'buddyboss' ),
					'type'        => 'integer',
				),
				'option_order'      => array(
					'context'     => array( 'embed', 'view', 'edit' ),
					'description' => __( 'The order of the option into the profile field list of options', 'buddyboss' ),
					'type'        => 'integer',
				),
				'order_by'          => array(
					'context'     => array( 'embed', 'view', 'edit' ),
					'description' => __( 'The way profile field\'s options are ordered.', 'buddyboss' ),
					'default'     => 'asc',
					'type'        => 'string',
					'enum'        => array( 'asc', 'desc' ),
				),
				'is_default_option' => array(
					'context'     => array( 'embed', 'view', 'edit' ),
					'description' => __( 'Whether the option is the default one for the profile field.', 'buddyboss' ),
					'type'        => 'boolean',
				),
				'visibility_level'  => array(
					'context'     => array( 'embed', 'view', 'edit' ),
					'description' => __( 'Who may see the saved value for this profile field.', 'buddyboss' ),
					'default'     => 'public',
					'type'        => 'string',
					'enum'        => array_keys( bp_xprofile_get_visibility_levels() ),
				),
				'options'           => array(
					'context'     => array( 'embed', 'view', 'edit' ),
					'description' => __( 'Options of the profile field.', 'buddyboss' ),
					'type'        => 'array',
					'readonly'    => true,
				),
				'data'              => array(
					'context'     => array( 'embed', 'view', 'edit' ),
					'description' => __( 'The saved value for this profile field.', 'buddyboss' ),
					'type'        => 'object',
					'readonly'    => true,
					'properties'  => array(
						'raw'          => array(
							'description' => __( 'Value for the field, as it exists in the database.', 'buddyboss' ),
							'type'        => 'string',
							'context'     => array( 'embed', 'view', 'edit' ),
						),
						'unserialized' => array(
							'description' => __( 'Unserialized value for the field, regular string will be casted as array.', 'buddyboss' ),
							'type'        => 'array',
							'context'     => array( 'embed', 'view', 'edit' ),
							'readonly'    => true,
						),
						'rendered'     => array(
							'description' => __( 'HTML value for the field, transformed for display.', 'buddyboss' ),
							'type'        => 'string',
							'context'     => array( 'embed', 'view', 'edit' ),
							'readonly'    => true,
						),
					),
				),
			),
		);

		/**
		 * Filters the xprofile field schema.
		 *
		 * @param array $schema The endpoint schema.
		 */
		return apply_filters( 'bp_rest_xprofile_field_schema', $this->add_additional_fields_schema( $schema ) );
	}

Changelog

Changelog
Version Description
0.1.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.