messages_action_conversation

Process a request to view a single message thread.

Description

messages_action_conversation(); 

Usage

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

Defined (1)

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

/bp-messages/bp-messages-actions.php  
  1. function messages_action_conversation() { 
  2.  
  3. // Bail if not viewing a single conversation. 
  4. if ( ! bp_is_messages_component() || ! bp_is_current_action( 'view' ) ) { 
  5. return false; 
  6.  
  7. // Get the thread ID from the action variable. 
  8. $thread_id = (int) bp_action_variable( 0 ); 
  9.  
  10. if ( ! messages_is_valid_thread( $thread_id ) || ( ! messages_check_thread_access( $thread_id ) && ! bp_current_user_can( 'bp_moderate' ) ) ) { 
  11.  
  12. // Check if a new reply has been submitted. 
  13. if ( isset( $_POST['send'] ) ) { 
  14.  
  15. // Check the nonce. 
  16. check_admin_referer( 'messages_send_message', 'send_message_nonce' ); 
  17.  
  18. $new_reply = messages_new_message( array( 
  19. 'thread_id' => $thread_id,  
  20. 'subject' => ! empty( $_POST['subject'] ) ? $_POST['subject'] : false,  
  21. 'content' => $_POST['content'] 
  22. ) ); 
  23.  
  24. // Send the reply. 
  25. if ( ! empty( $new_reply ) ) { 
  26. bp_core_add_message( __( 'Your reply was sent successfully', buddypress ) ); 
  27. } else { 
  28. bp_core_add_message( __( 'There was a problem sending your reply. Please try again.', buddypress ), error ); 
  29.  
  30. bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id . '/' ); 
  31.  
  32. // Mark message read. 
  33. messages_mark_thread_read( $thread_id ); 
  34.  
  35. /** 
  36. * Fires after processing a view request for a single message thread. 
  37. * @since 1.7.0 
  38. */