bp_groupblog_remove_post

When a blog post is deleted, delete the activity item.

Description

bp_groupblog_remove_post( (int) $post_id, (int) $blog_id = 0, (int) $user_id = 0 ); 

Parameters (3)

0. $post_id (int)
The post id.
1. $blog_id — Optional. (int)
The blog id.
2. $user_id — Optional. (int)
The user id.

Usage

  1. if ( !function_exists( 'bp_groupblog_remove_post' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bp-groupblog/bp-groupblog.php'; 
  3.  
  4. // The post id. 
  5. $post_id = -1; 
  6.  
  7. // The blog id. 
  8. $blog_id = -1; 
  9.  
  10. // The user id. 
  11. $user_id = -1; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bp_groupblog_remove_post($post_id, $blog_id, $user_id); 
  15.  

Defined (1)

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

/bp-groupblog.php  
  1. function bp_groupblog_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) { 
  2. // Bail if the activity or blogs components are not enabled 
  3. if ( ! bp_is_active( 'blogs' ) || ! bp_is_active( 'activity' ) ) { 
  4. return; 
  5.  
  6. global $wpdb, $bp; 
  7.  
  8. $post_id = (int) $post_id; 
  9.  
  10. if ( !$blog_id ) 
  11. $blog_id = get_current_blog_id(); 
  12.  
  13. if ( !$user_id ) 
  14. $user_id = bp_loggedin_user_id(); 
  15.  
  16. $group_id = get_groupblog_group_id( $blog_id ); 
  17.  
  18. if ( ! $group_id ) { 
  19. return false; 
  20.  
  21. do_action( 'bp_groupblog_before_remove_post', $blog_id, $post_id, $user_id, $group_id ); 
  22.  
  23. // Delete activity stream item 
  24. bp_blogs_delete_activity( array( 
  25. 'item_id' => $group_id,  
  26. 'secondary_item_id' => $post_id,  
  27. 'type' => 'new_groupblog_post',  
  28. 'component' => $bp->groups->id 
  29. ) ); 
  30.  
  31. do_action( 'bp_groupblog_remove_post', $blog_id, $post_id, $user_id, $group_id );