bp_dtheme_ajax_message_markread

Mark a private message as read in your inbox via a POST request.

Description

bp_dtheme_ajax_message_markread(); 

Usage

  1. if ( !function_exists( 'bp_dtheme_ajax_message_markread' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-themes/bp-default/_inc/ajax.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_dtheme_ajax_message_markread(); 
  7.  

Defined (1)

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

/bp-themes/bp-default/_inc/ajax.php  
  1. function bp_dtheme_ajax_message_markread() { 
  2. // Bail if not a POST action 
  3. if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) 
  4. return; 
  5.  
  6. $nonce_check = isset( $_POST['nonce'] ) && wp_verify_nonce( wp_unslash( $_POST['nonce'] ), 'bp_messages_mark_messages_read' ); 
  7.  
  8. if ( ! $nonce_check || ! isset( $_POST['thread_ids'] ) ) { 
  9. echo "-1<div id='message' class=error><p>" . __('There was a problem marking messages as read.', buddypress ) . '</p></div>'; 
  10.  
  11. } else { 
  12. $thread_ids = explode( ', ', $_POST['thread_ids'] ); 
  13.  
  14. for ( $i = 0, $count = count( $thread_ids ); $i < $count; ++$i ) { 
  15. BP_Messages_Thread::mark_as_read( (int) $thread_ids[$i] ); 
  16.  
  17. exit;