bp_activity_spam_all_user_data( int $user_id )
Mark all of the user’s activity as spam.
Description
Parameters
- $user_id
-
(Required) ID of the user whose activity is being spammed.
Return
(bool)
Source
File: bp-activity/bp-activity-functions.php
function bp_activity_spam_all_user_data( $user_id = 0 ) { global $wpdb; // Do not delete user data unless a logged in user says so. if ( empty( $user_id ) || ! is_user_logged_in() ) { return false; } // Get all the user's activities. $activities = bp_activity_get( array( 'display_comments' => 'stream', 'filter' => array( 'user_id' => $user_id ), 'show_hidden' => true ) ); $bp = buddypress(); // Mark each as spam. foreach ( (array) $activities['activities'] as $activity ) { // Create an activity object. $activity_obj = new BP_Activity_Activity; foreach ( $activity as $k => $v ) { $activity_obj->$k = $v; } // Mark as spam. bp_activity_mark_as_spam( $activity_obj ); /* * If Akismet is present, update the activity history meta. * * This is usually taken care of when BP_Activity_Activity::save() happens, but * as we're going to be updating all the activity statuses directly, for efficiency, * we need to update manually. */ if ( ! empty( $bp->activity->akismet ) ) { $bp->activity->akismet->update_activity_spam_meta( $activity_obj ); } // Tidy up. unset( $activity_obj ); } // Mark all of this user's activities as spam. $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET is_spam = 1 WHERE user_id = %d", $user_id ) ); /** * Fires after all activity data from a user has been marked as spam. * * @since BuddyPress 1.6.0 * * @param int $user_id ID of the user whose activity is being marked as spam. * @param array $activities Array of activity items being marked as spam. */ do_action( 'bp_activity_spam_all_user_data', $user_id, $activities['activities'] ); }
Changelog
Version | Description |
---|---|
BuddyPress 1.6.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.