bp_docs_delete_doc_activity

Delete activity associated with a Doc.

Description

bp_docs_delete_doc_activity( (string) $new_status, (string) $old_status, (obj) $post ); 

Run on transition_post_status, to catch deletes from all locations

Parameters (3)

0. $new_status (string)
The new status.
1. $old_status (string)
The old status.
2. $post (obj)
WP_Post object

Usage

  1. if ( !function_exists( 'bp_docs_delete_doc_activity' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-docs/includes/activity.php'; 
  3.  
  4. // The new status. 
  5. $new_status = ''; 
  6.  
  7. // The old status. 
  8. $old_status = ''; 
  9.  
  10. // WP_Post object 
  11. $post = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bp_docs_delete_doc_activity($new_status, $old_status, $post); 
  15.  

Defined (1)

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

/includes/activity.php  
  1. function bp_docs_delete_doc_activity( $new_status, $old_status, $post ) { 
  2. if ( ! bp_is_active( 'activity' ) ) { 
  3. return; 
  4.  
  5. if ( bp_docs_get_post_type_name() != $post->post_type ) { 
  6. return; 
  7.  
  8. if ( 'trash' != $new_status ) { 
  9. return; 
  10.  
  11.  
  12. $activities = bp_activity_get( 
  13. array( 
  14. 'filter' => array( 
  15. 'secondary_id' => $post->ID,  
  16. 'component' => 'docs',  
  17. ),  
  18. ); 
  19.  
  20. foreach ( (array) $activities['activities'] as $activity ) { 
  21. bp_activity_delete( array( 'id' => $activity->id ) );