bp_activity_remove_all_user_data

Completely remove a user's activity data.

Description

bp_activity_remove_all_user_data( (int) $user_id = 0 ); 

Parameters (1)

0. $user_id — Optional. (int)
ID of the user whose activity is being deleted.

Usage

  1. if ( !function_exists( 'bp_activity_remove_all_user_data' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-functions.php'; 
  3.  
  4. // ID of the user whose activity is being deleted. 
  5. $user_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_activity_remove_all_user_data($user_id); 
  9.  

Defined (1)

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

/bp-activity/bp-activity-functions.php  
  1. function bp_activity_remove_all_user_data( $user_id = 0 ) { 
  2.  
  3. // Do not delete user data unless a logged in user says so. 
  4. if ( empty( $user_id ) || ! is_user_logged_in() ) { 
  5. return false; 
  6.  
  7. // Clear the user's activity from the sitewide stream and clear their activity tables. 
  8. bp_activity_delete( array( 'user_id' => $user_id ) ); 
  9.  
  10. // Remove any usermeta. 
  11. bp_delete_user_meta( $user_id, 'bp_latest_update' ); 
  12. bp_delete_user_meta( $user_id, 'bp_favorite_activities' ); 
  13.  
  14. // Execute additional code 
  15. do_action( 'bp_activity_remove_data', $user_id ); // Deprecated! Do not use! 
  16.  
  17. /** 
  18. * Fires after the removal of all of a user's activity data. 
  19. * @since 1.5.0 
  20. * @param int $user_id ID of the user being deleted. 
  21. */