bp_profile_message_ux_send_public_message

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

Description

bp_profile_message_ux_send_public_message(); 

Usage

  1. if ( !function_exists( 'bp_profile_message_ux_send_public_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_public_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_public_message() {  
  2.  
  3. if ( !is_user_logged_in() || !isset( $_POST['whats-new-profile-ux'] ) ) 
  4. return false; 
  5.  
  6. // Check the nonce 
  7. check_admin_referer( 'public_message_check' ); 
  8.  
  9. $content_feedback_empty = __( 'Please enter some content in the Public Message form.', 'bp-profile-message-ux' ); 
  10. $content_feedback_success = __( 'Your Public Message has been posted!', 'bp-profile-message-ux' ); 
  11. $content_feedback_error = __( 'There was anerrorwhen posting your Public Message, please try again.', 'bp-profile-message-ux' ); 
  12.  
  13. // Get public message content 
  14. $content = $_POST['whats-new-profile-ux']; 
  15.  
  16. // No public message so provide feedback and redirect 
  17. if ( empty( $content ) ) { 
  18. bp_core_add_message( $content_feedback_empty, error ); 
  19. bp_core_redirect( bp_displayed_user_domain() ); 
  20.  
  21. $activity_id = bp_activity_post_update( array( 'content' => $content ) ); 
  22.  
  23. // Provide user feedback 
  24. if ( !empty( $activity_id ) ) 
  25. bp_core_add_message( $content_feedback_success ); 
  26. else 
  27. bp_core_add_message( $content_feedback_error, error ); 
  28.  
  29. // Redirect 
  30. bp_core_redirect( bp_displayed_user_domain() );  
  31.