bp_messages_clear_cache_on_message_save

Clear message cache after a message is saved.

Description

bp_messages_clear_cache_on_message_save( (BP_Messages_Message) BP_Messages_Message $message ); 

Parameters (1)

0. $message (BP_Messages_Message) => BP_Messages_Message $message
Message being saved.

Usage

  1. if ( !function_exists( 'bp_messages_clear_cache_on_message_save' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-messages/bp-messages-cache.php'; 
  3.  
  4. // Message being saved. 
  5. $message = BP_Messages_Message $message; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_messages_clear_cache_on_message_save($message); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-messages/bp-messages-cache.php  
  1. function bp_messages_clear_cache_on_message_save( BP_Messages_Message $message ) { 
  2. // Delete thread cache. 
  3. wp_cache_delete( $message->thread_id, 'bp_messages_threads' ); 
  4.  
  5. // Delete unread count for each recipient. 
  6. foreach ( (array) $message->recipients as $recipient ) { 
  7. wp_cache_delete( $recipient->user_id, 'bp_messages_unread_count' ); 
  8.  
  9. // Delete thread recipient cache. 
  10. wp_cache_delete( 'thread_recipients_' . $message->thread_id, 'bp_messages' );