bp_nouveau_ajax_activity_update_privacy()

Update activity privacy via a POST request.

Description

Return

(string) JSON reply

Source

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

function bp_nouveau_ajax_activity_update_privacy() {
	if ( ! bp_is_post_request() ) {
		wp_send_json_error();
	}

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

	if ( empty( $_POST['privacy'] ) ) {
		wp_send_json_error();
	}

	if ( ! in_array( $_POST['privacy'], array( 'public', 'loggedin', 'onlyme', 'friends' ) ) ) {
		wp_send_json_error();
	}

	$activity = new BP_Activity_Activity( (int) $_POST['id'] );

	if ( bp_activity_user_can_delete( $activity ) ) {
		remove_action( 'bp_activity_before_save', 'bp_activity_check_moderation_keys', 2 );
		$activity->privacy = $_POST['privacy'];
		$activity->save();
		add_action( 'bp_activity_before_save', 'bp_activity_check_moderation_keys', 2 );

		wp_send_json_success( array() );
	} else {
		wp_send_json_error();
	}
}

Changelog

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