bp_nouveau_ajax_document_activity_delete()

Description

Source

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

function bp_nouveau_ajax_document_activity_delete() {

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

	// Bail if not a POST action.
	if ( ! bp_is_post_request() ) {
		wp_send_json_error( $response );
	}

	$id            = ! empty( $_POST['id'] ) ? (int) $_POST['id'] : 0;
	$attachment_id = ! empty( $_POST['attachment_id'] ) ? (int) $_POST['attachment_id'] : 0;
	$type          = ! empty( $_POST['type'] ) ? $_POST['type'] : '';
	$activity_id   = ! empty( $_POST['activity_id'] ) ? $_POST['activity_id'] : 0;

	if ( '' === $type ) {
		wp_send_json_error( $response );
	}

	if ( bp_document_user_can_delete( $id ) ) {
		$args = array(
			'id'            => $id,
			'attachment_id' => $attachment_id,
		);
		bp_document_delete( $args );
	}

	$delete_box = false;

	// Get activity object.
	$activity = new BP_Activity_Activity( $activity_id );
	if ( empty( $activity->id ) ) {
		$delete_box = true;
	}

	wp_send_json_success(
		array(
			'message'         => 'success',
			'delete_activity' => $delete_box,
		)
	);
}

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.