Changeset 5410 for trunk/bp-activity/bp-activity-functions.php
- Timestamp:
- 11/29/2011 08:45:28 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-functions.php
r5368 r5410 661 661 662 662 // Do not delete user data unless a logged in user says so 663 if ( empty( $user_id ) || ! is_user_logged_in() )663 if ( empty( $user_id ) || ! is_user_logged_in() ) 664 664 return false; 665 665 … … 699 699 } 700 700 add_action( 'bp_make_spam_user', 'bp_activity_spam_all_user_data' ); 701 702 /** 703 * Mark all of the user's activity as ham (not spam) 704 * 705 * @global object $wpdb 706 * @global object $bp BuddyPress global settings 707 * @param int $user_id 708 * @since 1.6 709 */ 710 function bp_activity_ham_all_user_data( $user_id = 0 ) { 711 global $bp, $wpdb; 712 713 // Do not delete user data unless a logged in user says so 714 if ( empty( $user_id ) || ! is_user_logged_in() ) 715 return false; 716 717 // Get all the user's activities. 718 $activities = bp_activity_get( array( 'display_comments' => 'stream', 'filter' => array( 'user_id' => $user_id ), 'show_hidden' => true, 'spam' => 'all', ) ); 719 720 // Mark each as not spam 721 foreach ( (array) $activities['activities'] as $activity ) { 722 723 // Create an activity object 724 $activity_obj = new BP_Activity_Activity; 725 foreach ( $activity as $k => $v ) 726 $activity_obj->$k = $v; 727 728 // Mark as not spam 729 bp_activity_mark_as_ham( $activity_obj ); 730 731 /* 732 * If Akismet is present, update the activity history meta. 733 * 734 * This is usually taken care of when BP_Activity_Activity::save() happens, but 735 * as we're going to be updating all the activity statuses directly, for efficency, 736 * we need to update manually. 737 */ 738 if ( ! empty( $bp->activity->akismet ) ) 739 $bp->activity->akismet->update_activity_ham_meta( $activity_obj ); 740 741 // Tidy up 742 unset( $activity_obj ); 743 } 744 745 // Mark all of this user's activities as spam 746 $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET is_spam = 0 WHERE user_id = %d", $user_id ) ); 747 748 // Call an action for plugins to use 749 do_action( 'bp_activity_ham_all_user_data', $user_id, $activities['activities'] ); 750 } 751 add_action( 'bp_make_ham_user', 'bp_activity_ham_all_user_data' ); 701 752 702 753 /**
Note: See TracChangeset
for help on using the changeset viewer.