bp_activity_ham_all_user_data( int $user_id )
Mark all of the user’s activity as ham (not spam).
Description
Parameters
- $user_id
-
(Required) ID of the user whose activity is being hammed.
Return
(bool)
Source
File: bp-activity/bp-activity-functions.php
1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 | function bp_activity_ham_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, 'spam' => 'all' ) ); $bp = buddypress(); // Mark each as not 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 not spam. bp_activity_mark_as_ham( $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_ham_meta( $activity_obj ); } // Tidy up. unset( $activity_obj ); } // Mark all of this user's activities as not spam. $wpdb ->query( $wpdb ->prepare( "UPDATE {$bp->activity->table_name} SET is_spam = 0 WHERE user_id = %d" , $user_id ) ); /** * Fires after all activity data from a user has been marked as ham. * * @since BuddyPress 1.6.0 * * @param int $user_id ID of the user whose activity is being marked as ham. * @param array $activities Array of activity items being marked as ham. */ do_action( 'bp_activity_ham_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.