bp_messages_action_mark_unread

Handle marking a single message thread as unread.

Description

(bool|null) bp_messages_action_mark_unread(); 

Returns (bool|null)

Returns false on failure. Otherwise redirects back to the message box URL.


Usage

  1. if ( !function_exists( 'bp_messages_action_mark_unread' ) ) { 
  2. require_once '/bp-messages/bp-messages-actions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_messages_action_mark_unread(); 
  7.  

Defined (1)

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

/bp-messages/bp-messages-actions.php  
  1. function bp_messages_action_mark_unread() { 
  2.  
  3. if ( ! bp_is_messages_component() || bp_is_current_action( 'notices' ) || ! bp_is_action_variable( 'unread', 0 ) ) { 
  4. return false; 
  5.  
  6. $action = ! empty( $_GET['action'] ) ? $_GET['action'] : ''; 
  7. $nonce = ! empty( $_GET['_wpnonce'] ) ? $_GET['_wpnonce'] : ''; 
  8. $id = ! empty( $_GET['message_id'] ) ? intval( $_GET['message_id'] ) : ''; 
  9.  
  10. // Bail if no action or no ID. 
  11. if ( 'unread' !== $action || empty( $id ) || empty( $nonce ) ) { 
  12. return false; 
  13.  
  14. // Check the nonce. 
  15. if ( ! bp_verify_nonce_request( 'bp_message_thread_mark_unread_' . $id ) ) { 
  16. return false; 
  17.  
  18. // Check access to the message and mark unread. 
  19. if ( messages_check_thread_access( $id ) ) { 
  20. messages_mark_thread_unread( $id ); 
  21. bp_core_add_message( __( 'Message marked unread.', 'buddypress' ) ); 
  22. } else { 
  23. bp_core_add_message( __( 'There was a problem marking that message.', 'buddypress' ), 'error' ); 
  24.  
  25. // Redirect back to the message box URL. 
  26. bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() );