bp_nouveau_ajax_media_description_save()

Update media activity description.

Description

Source

File: bp-templates/bp-nouveau/includes/media/ajax.php

function bp_nouveau_ajax_media_description_save() {
	$response = array(
		'feedback' => sprintf(
			'<div class="bp-feedback bp-messages error"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>',
			esc_html__( 'There was a problem. Please try again.', 'buddyboss' )
		),
	);

	// Nonce check!
	if ( empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'bp_nouveau_media' ) ) {
		wp_send_json_error( $response );
	}

	$attachment_id = $_POST['attachment_id'];
	$description = $_POST['description'];

	$attachment = get_post( $attachment_id );

	if ( empty( $attachment ) && ( 'attachment' !== $attachment->post_type ) ) {
		$response['feedback'] = sprintf(
			'<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>',
			esc_html__( 'There was an error for updating a description. Please try again.', 'buddyboss' )
		);

		wp_send_json_error( $response );
	}

	$media_post['ID']           = $attachment_id;
	$media_post['post_content'] = $description;
	wp_update_post( $media_post );

	$response['description'] = $description;
	wp_send_json_success( $response );
}

Changelog

Changelog
Version Description
BuddyBoss 1.3.5 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.