bp_activity_action_post_update

Post user/group activity update.

Description

bp_activity_action_post_update(); 

Usage

  1. if ( !function_exists( 'bp_activity_action_post_update' ) ) { 
  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_update(); 
  7.  

Defined (1)

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

/bp-activity/bp-activity-actions.php  
  1. function bp_activity_action_post_update() { 
  2.  
  3. // Do not proceed if user is not logged in, not viewing activity, or not posting. 
  4. if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'post' ) ) 
  5. return false; 
  6.  
  7. // Check the nonce. 
  8. check_admin_referer( 'post_update', '_wpnonce_post_update' ); 
  9.  
  10. /** 
  11. * Filters the content provided in the activity input field. 
  12. * @since 1.2.0 
  13. * @param string $value Activity message being posted. 
  14. */ 
  15. $content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] ); 
  16.  
  17. if ( ! empty( $_POST['whats-new-post-object'] ) ) { 
  18.  
  19. /** 
  20. * Filters the item type that the activity update should be associated with. 
  21. * @since 1.2.0 
  22. * @param string $value Item type to associate with. 
  23. */ 
  24. $object = apply_filters( 'bp_activity_post_update_object', $_POST['whats-new-post-object'] ); 
  25.  
  26. if ( ! empty( $_POST['whats-new-post-in'] ) ) { 
  27.  
  28. /** 
  29. * Filters what component the activity is being to. 
  30. * @since 1.2.0 
  31. * @param string $value Chosen component to post activity to. 
  32. */ 
  33. $item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] ); 
  34.  
  35. // No activity content so provide feedback and redirect. 
  36. if ( empty( $content ) ) { 
  37. bp_core_add_message( __( 'Please enter some content to post.', buddypress ), error ); 
  38.  
  39. // No existing item_id. 
  40. if ( empty( $item_id ) ) { 
  41. $activity_id = bp_activity_post_update( array( 'content' => $content ) ); 
  42.  
  43. // Post to groups object. 
  44. } elseif ( 'groups' == $object && bp_is_active( 'groups' ) ) { 
  45. if ( (int) $item_id ) { 
  46. $activity_id = groups_post_update( array( 'content' => $content, 'group_id' => $item_id ) ); 
  47.  
  48. } else { 
  49.  
  50. /** 
  51. * Filters activity object for BuddyPress core and plugin authors before posting activity update. 
  52. * @since 1.2.0 
  53. * @param string $object Activity item being associated to. 
  54. * @param string $item_id Component ID being posted to. 
  55. * @param string $content Activity content being posted. 
  56. */ 
  57. $activity_id = apply_filters( 'bp_activity_custom_update', $object, $item_id, $content ); 
  58.  
  59. // Provide user feedback. 
  60. if ( !empty( $activity_id ) ) 
  61. bp_core_add_message( __( 'Update Posted!', buddypress ) ); 
  62. else 
  63. bp_core_add_message( __( 'There was anerrorwhen posting your update. Please try again.', buddypress ), error ); 
  64.  
  65. // Redirect.