bp_attachments_json_response( bool $success, bool $is_html4 = false, mixed $data = null )

Send a JSON response back to an Ajax upload request.

Description

Parameters

$success

(bool) (Required) True for a success, false otherwise.

$is_html4

(bool) (Optional) True if the Plupload runtime used is html4, false otherwise.

Default value: false

$data

(mixed) (Optional) Data to encode as JSON, then print and die.

Default value: null

Source

File: bp-core/bp-core-attachments.php

function bp_attachments_json_response( $success, $is_html4 = false, $data = null ) {
	$response = array( 'success' => $success );

	if ( isset( $data ) ) {
		$response['data'] = $data;
	}

	// Send regular json response.
	if ( ! $is_html4 ) {
		wp_send_json( $response );

	/**
	 * Send specific json response
	 * the html4 Plupload handler requires a text/html content-type for older IE.
	 * See https://core.trac.wordpress.org/ticket/31037
	 */
	} else {
		echo wp_json_encode( $response );

		wp_die();
	}
}

Changelog

Changelog
Version Description
BuddyPress 2.3.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.