bp_messages_clear_cache_on_message_save( BP_Messages_Message $message )

Clear message cache after a message is saved.


Parameters Parameters

$message

(BP_Messages_Message) (Required) Message being saved.


Source Source

File: bp-messages/bp-messages-cache.php

function bp_messages_clear_cache_on_message_save( BP_Messages_Message $message ) {
	// Delete thread cache.
	wp_cache_delete( $message->thread_id, 'bp_messages_threads' );

	// Delete unread count for each recipient.
	foreach ( (array) $message->recipients as $recipient ) {
		wp_cache_delete( $recipient->user_id, 'bp_messages_unread_count' );
	}

	// Delete thread recipient cache.
	wp_cache_delete( 'thread_recipients_' . $message->thread_id, 'bp_messages' );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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