bp_profile_message_ux_send_private_message

The BP Profile Message UX bp profile message ux send private function.

Description

bp_profile_message_ux_send_private_message(); 

Usage

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

Defined (1)

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

/bp-profile-message-ux.php  
  1. function bp_profile_message_ux_send_private_message() {  
  2.  
  3. if ( !is_user_logged_in() || !isset($_POST['private-message-hidden']) )  
  4. return; 
  5.  
  6. check_admin_referer("private_message_check"); 
  7.  
  8. $content_feedback_empty = __( 'Please enter some content in the Private Message form.', 'bp-profile-message-ux' ); 
  9. $content_feedback_success = __( 'Private Message was sent!', 'bp-profile-message-ux' ); 
  10. $content_feedback_error = __( 'There was anerrorsending that Private Message. Please make sure you fill out both fields.', 'bp-profile-message-ux' ); 
  11.  
  12. // No private message so provide feedback and redirect 
  13. if ( empty( $_POST['private_message_content'] ) ) { 
  14. bp_core_add_message( $content_feedback_empty, error ); 
  15. bp_core_redirect( bp_displayed_user_domain() ); 
  16. }  
  17.  
  18.  
  19. $sender_id = bp_loggedin_user_id(); 
  20. $recip_id = bp_displayed_user_id(); 
  21.  
  22.  
  23. if ( $thread_id = messages_new_message( array('sender_id' => $sender_id, 'subject' => $_POST['private_message_subject'], 'content' => $_POST['private_message_content'], 'recipients' => $recip_id ) ) )  
  24. bp_core_add_message( $content_feedback_success ); 
  25.  
  26. else  
  27. bp_core_add_message( $content_feedback_error, error ); 
  28.  
  29. bp_core_redirect( bp_displayed_user_domain() ); 
  30.