bp_activity_action_post_comment

Post new activity comment.

Description

bp_activity_action_post_comment(); 

Usage

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

Defined (1)

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

/bp-activity/bp-activity-actions.php  
  1. function bp_activity_action_post_comment() { 
  2.  
  3. if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'reply' ) ) 
  4. return false; 
  5.  
  6. // Check the nonce. 
  7. check_admin_referer( 'new_activity_comment', '_wpnonce_new_activity_comment' ); 
  8.  
  9. /** 
  10. * Filters the activity ID a comment will be in reply to. 
  11. * @since 1.2.0 
  12. * @param string $value ID of the activity being replied to. 
  13. */ 
  14. $activity_id = apply_filters( 'bp_activity_post_comment_activity_id', $_POST['comment_form_id'] ); 
  15.  
  16. /** 
  17. * Filters the comment content for a comment reply. 
  18. * @since 1.2.0 
  19. * @param string $value Comment content being posted. 
  20. */ 
  21. $content = apply_filters( 'bp_activity_post_comment_content', $_POST['ac_input_' . $activity_id] ); 
  22.  
  23. if ( empty( $content ) ) { 
  24. bp_core_add_message( __( 'Please do not leave the comment area blank.', buddypress ), error ); 
  25. bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id ); 
  26.  
  27. $comment_id = bp_activity_new_comment( array( 
  28. 'content' => $content,  
  29. 'activity_id' => $activity_id,  
  30. 'parent_id' => false 
  31. )); 
  32.  
  33. if ( !empty( $comment_id ) ) 
  34. bp_core_add_message( __( 'Reply Posted!', buddypress ) ); 
  35. else 
  36. bp_core_add_message( __( 'There was anerrorposting that reply. Please try again.', buddypress ), error ); 
  37.  
  38. bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id );