bp_dtheme_ajax_messages_delete()

Delete a private message(s) in your inbox via a POST request.


Description Description


Return Return

(string) HTML


Top ↑

Source Source

File: bp-themes/bp-default/_inc/ajax.php

function bp_dtheme_ajax_messages_delete() {
	// Bail if not a POST action
	if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
		return;

	$nonce_check = isset( $_POST['nonce'] ) && wp_verify_nonce( wp_unslash( $_POST['nonce'] ), 'bp_messages_delete_selected' );

	if ( ! $nonce_check || ! isset($_POST['thread_ids']) ) {
		echo "-1<div id='message' class='error'><p>" . __( 'There was a problem deleting messages.', 'buddypress' ) . '</p></div>';

	} else {
		$thread_ids = explode( ',', $_POST['thread_ids'] );

		for ( $i = 0, $count = count( $thread_ids ); $i < $count; ++$i ) {
			BP_Messages_Thread::delete( (int) $thread_ids[$i] );
		}

		_e( 'Messages deleted.', 'buddypress' );
	}

	exit;
}

Top ↑

Changelog Changelog

Changelog
Version Description
BuddyPress (1.2) Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.