BP_REST_Invites_Endpoint::get_endpoint_args_for_item_schema( string $method = WP_REST_Server::CREATABLE )

Edit some arguments for the endpoint’s CREATABLE and EDITABLE methods.

Description

Parameters

$method

(Optional) HTTP method of the request.

Default value: WP_REST_Server::CREATABLE

Return

(array) Endpoint arguments.

Source

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

	public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE ) {
		$args = WP_REST_Controller::get_endpoint_args_for_item_schema( $method );
		$key  = 'create_item';

		if ( WP_REST_Server::CREATABLE === $method ) {
			$args = array(
				'fields' => array(
					'description' => __( 'Fields array with name and email_id to create an invites.', 'buddyboss' ),
					'type'        => 'array',
					'items'       => array( 'type' => 'object' ),
					'required'    => true,
					'properties'  => array(
						'name'     => array(
							'description'       => __( 'Recipient Name for the invite.', 'buddyboss' ),
							'type'              => 'string',
							'required'          => true,
							'sanitize_callback' => 'sanitize_text_field',
							'validate_callback' => 'rest_validate_request_arg',
						),
						'email_id' => array(
							'description'       => __( 'Recipient Email for the invite.', 'buddyboss' ),
							'type'              => 'string',
							'required'          => true,
							'sanitize_callback' => 'sanitize_text_field',
							'validate_callback' => 'rest_validate_request_arg',
						),
					),
				),
			);

			if ( true === bp_check_member_send_invites_tab_member_type_allowed() ) {
				$args['fields']['description']                = __( 'Fields array with name, email_id and profile_type to create an invites.', 'buddyboss' );
				$args['fields']['properties']['profile_type'] = array(
					'description'       => __( 'Profile Type for the invite.', 'buddyboss' ),
					'type'              => 'string',
					'required'          => true,
					'sanitize_callback' => 'sanitize_text_field',
					'validate_callback' => 'rest_validate_request_arg',
				);
			}

			if ( true === bp_disable_invite_member_email_subject() ) {
				$args['email_subject'] = array(
					'description'       => __( 'Subject for invite a member.', 'buddyboss' ),
					'type'              => 'string',
					'default'           => stripslashes( wp_strip_all_tags( bp_get_member_invitation_subject() ) ),
					'validate_callback' => 'rest_validate_request_arg',
				);
			}

			if ( true === bp_disable_invite_member_email_content() ) {
				$args['email_content'] = array(
					'description'       => __( 'Content for invite a member.', 'buddyboss' ),
					'type'              => 'string',
					'default'           => bp_get_member_invites_wildcard_replace( bp_get_member_invitation_message() ),
					'validate_callback' => 'rest_validate_request_arg',
				);
			}
		}

		/**
		 * Filters the method query arguments.
		 *
		 * @param array  $args   Query arguments.
		 * @param string $method HTTP method of the request.
		 *
		 * @since 0.1.0
		 */
		return apply_filters( "bp_rest_invites_{$key}_query_arguments", $args, $method );
	}

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.