BP_REST_Members_Endpoint::get_item_schema()

Get the members schema, conforming to JSON Schema.


Return Return

(array)


Source Source

File: bp-members/classes/class-bp-rest-members-endpoint.php

	public function get_item_schema() {
		if ( is_null( $this->schema ) ) {
			$schema = array(
				'$schema'    => 'http://json-schema.org/draft-04/schema#',
				'title'      => 'bp_members',
				'type'       => 'object',
				'properties' => array(
					'id'                 => array(
						'description' => __( 'A unique numeric ID for the Member.', 'buddypress' ),
						'type'        => 'integer',
						'context'     => array( 'view', 'edit', 'embed' ),
						'readonly'    => true,
					),
					'name'               => array(
						'description' => __( 'Display name for the member.', 'buddypress' ),
						'type'        => 'string',
						'context'     => array( 'view', 'edit' ),
						'arg_options' => array(
							'sanitize_callback' => 'sanitize_text_field',
						),
					),
					'mention_name'       => array(
						'description' => __( 'The name used for that user in @-mentions.', 'buddypress' ),
						'type'        => 'string',
						'context'     => array( 'view', 'edit', 'embed' ),
						'arg_options' => array(
							'sanitize_callback' => 'sanitize_text_field',
						),
						'readonly'    => true,
					),
					'link'               => array(
						'description' => __( 'Profile URL of the member.', 'buddypress' ),
						'type'        => 'string',
						'format'      => 'uri',
						'context'     => array( 'view', 'edit', 'embed' ),
						'readonly'    => true,
					),
					'user_login'         => array(
						'description' => __( 'An alphanumeric identifier for the Member.', 'buddypress' ),
						'type'        => 'string',
						'context'     => array( 'view', 'edit', 'embed' ),
						'required'    => true,
						'arg_options' => array(
							'sanitize_callback' => array( $this, 'check_username' ),
						),
					),
					'member_types'       => array(
						'description' => __( 'Member types associated with the member.', 'buddypress' ),
						'enum'        => bp_get_member_types(),
						'type'        => 'array',
						'items'       => array(
							'type' => 'string',
						),
						'context'     => array( 'view', 'edit', 'embed' ),
						'readonly'    => true,
					),
					'registered_date'    => array(
						'description' => __( 'Registration date for the member.', 'buddypress' ),
						'type'        => 'string',
						'format'      => 'date-time',
						'context'     => array( 'edit' ),
						'readonly'    => true,
					),
					'password'           => array(
						'description' => __( 'Password for the member (never included).', 'buddypress' ),
						'type'        => 'string',
						'context'     => array(), // Password is never displayed.
						'required'    => true,
						'arg_options' => array(
							'sanitize_callback' => array( $this, 'check_user_password' ),
						),
					),
					'roles'              => array(
						'description' => __( 'Roles assigned to the member.', 'buddypress' ),
						'type'        => 'array',
						'context'     => array( 'edit' ),
						'items'       => array(
							'type' => 'string',
						),
					),
					'capabilities'       => array(
						'description' => __( 'All capabilities assigned to the user.', 'buddypress' ),
						'type'        => 'object',
						'context'     => array( 'edit' ),
						'readonly'    => true,
					),
					'extra_capabilities' => array(
						'description' => __( 'Any extra capabilities assigned to the user.', 'buddypress' ),
						'type'        => 'object',
						'context'     => array( 'edit' ),
						'readonly'    => true,
					),
					'xprofile'             => array(
						'description' => __( 'Member XProfile groups and its fields.', 'buddypress' ),
						'type'        => 'array',
						'context'     => array( 'view', 'edit' ),
						'readonly'    => true,
					),
					'friendship_status'    => array(
						'description' => __( 'Friendship relation with, current, logged in user.', 'buddypress' ),
						'type'        => 'bool',
						'context'     => array( 'view', 'edit', 'embed' ),
						'readonly'    => true,
					),
					'friendship_status_slug' => array(
						'description' => __( 'Slug of the friendship status with current logged in user.', 'buddypress' ),
						'enum'        => array( 'is_friend', 'not_friends', 'pending', 'awaiting_response' ),
						'type'        => 'string',
						'context'     => array( 'view', 'edit', 'embed' ),
						'readonly'    => true,
					),
					'last_activity'          => array(
						'description' => __( 'Last date the member was active on the site.', 'buddypress' ),
						'type'        => 'object',
						'properties'  => array(
							'timediff' => array(
								'type' => 'string',
							),
							'date'     => array(
								'type'   => 'string',
								'format' => 'date-time',
							),
						),
						'format'      => 'date-time',
						'context'     => array( 'view', 'edit' ),
						'readonly'    => true,
					),
					'latest_update'          => array(
						'description' => __( 'The content of the latest activity posted by the member.', 'buddypress' ),
						'type'        => 'object',
						'properties'  => array(
							'id'       => array(
								'context'     => array( 'view', 'edit' ),
								'description' => __( 'A unique numeric ID for the activity.', 'buddypress' ),
								'readonly'    => true,
								'type'        => 'integer',
							),
							'raw'      => array(
								'description' => __( 'Content for the activity, as it exists in the database.', 'buddypress' ),
								'type'        => 'string',
								'context'     => array( 'view', 'edit' ),
							),
							'rendered' => array(
								'description' => __( 'HTML content for the activity, transformed for display.', 'buddypress' ),
								'type'        => 'string',
								'context'     => array( 'view', 'edit' ),
								'readonly'    => true,
							),
						),
						'readonly'    => true,
					),
					'total_friend_count'     => array(
						'context'     => array( 'view', 'edit', 'embed' ),
						'description' => __( 'Total number of friends for the member.', 'buddypress' ),
						'type'        => 'integer',
						'readonly'    => true,
					),
				),
			);

			if ( true === buddypress()->avatar->show_avatars ) {
				$avatar_properties = array();

				$avatar_properties['full'] = array(
					/* translators: 1: Full avatar width in pixels. 2: Full avatar height in pixels */
					'description' => sprintf( __( 'Avatar URL with full image size (%1$d x %2$d pixels).', 'buddypress' ), number_format_i18n( bp_core_avatar_full_width() ), number_format_i18n( bp_core_avatar_full_height() ) ),
					'type'        => 'string',
					'format'      => 'uri',
					'context'     => array( 'view', 'edit' ),
				);

				$avatar_properties['thumb'] = array(
					/* translators: 1: Thumb avatar width in pixels. 2: Thumb avatar height in pixels */
					'description' => sprintf( __( 'Avatar URL with thumb image size (%1$d x %2$d pixels).', 'buddypress' ), number_format_i18n( bp_core_avatar_thumb_width() ), number_format_i18n( bp_core_avatar_thumb_height() ) ),
					'type'        => 'string',
					'format'      => 'uri',
					'context'     => array( 'view', 'edit' ),
				);

				$schema['properties']['avatar_urls'] = array(
					'description' => __( 'Avatar URLs for the member.', 'buddypress' ),
					'type'        => 'object',
					'context'     => array( 'view', 'edit' ),
					'readonly'    => true,
					'properties'  => $avatar_properties,
				);
			}

			// Cache current schema here.
			$this->schema = $schema;
		}

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


Top ↑

Changelog Changelog

Changelog
Version Description
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.