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
1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 | 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.