bp_dtheme_post_update

Processes Activity updates received via a POST request.

Description

(string) bp_dtheme_post_update(); 

Returns (string)

HTML


Usage

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

Defined (1)

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

/bp-themes/bp-default/_inc/ajax.php  
  1. function bp_dtheme_post_update() { 
  2. // Bail if not a POST action 
  3. if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) 
  4. return; 
  5.  
  6. // Check the nonce 
  7. check_admin_referer( 'post_update', '_wpnonce_post_update' ); 
  8.  
  9. if ( ! is_user_logged_in() ) 
  10. exit( '-1' ); 
  11.  
  12. if ( empty( $_POST['content'] ) ) 
  13. exit( '-1<div id="message" class="error"><p>' . __( 'Please enter some content to post.', buddypress ) . '</p></div>' ); 
  14.  
  15. $activity_id = 0; 
  16. if ( empty( $_POST['object'] ) && bp_is_active( 'activity' ) ) { 
  17. $activity_id = bp_activity_post_update( array( 'content' => $_POST['content'], 'error_type' => wp_error ) ); 
  18.  
  19. } elseif ( $_POST['object'] == 'groups' ) { 
  20. if ( ! empty( $_POST['item_id'] ) && bp_is_active( 'groups' ) ) 
  21. $activity_id = groups_post_update( array( 'content' => $_POST['content'], 'group_id' => $item_id, 'error_type' => wp_error ) ); 
  22.  
  23. } else { 
  24. $activity_id = apply_filters( 'bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content'] ); 
  25.  
  26. if ( false === $activity_id ) { 
  27. exit( '-1<div id="message" class="error"><p>' . __( 'There was a problem posting your update, please try again.', buddypress ) . '</p></div>' ); 
  28. } elseif ( is_wp_error( $activity_id ) && $activity_id->get_error_code() ) { 
  29. exit( '-1<div id="message" class="error bp-ajax-message"><p>' . $activity_id->get_error_message() . '</p></div>' ); 
  30.  
  31. if ( bp_has_activities ( 'include=' . $activity_id ) ) { 
  32. while ( bp_activities() ) { 
  33. locate_template( array( 'activity/entry.php' ), true ); 
  34.  
  35. exit;