bp_activity_recurse_comments_user_ids( array $comments = array() )
Recurse through all activity comments and collect the IDs of the users who wrote them.
Description
Parameters
- $comments
-
(Optional) Array of BP_Activity_Activity items.
Default value: array()
Return
(array) Array of user IDs.
Source
File: bp-activity/bp-activity-template.php
function bp_activity_recurse_comments_user_ids( array $comments = array() ) {
// Default user ID's array.
$user_ids = array();
// Loop through comments and try to get user ID's.
if ( ! empty( $comments ) ) {
foreach ( $comments as $comment ) {
// If a user is a spammer, their activity items will have been
// automatically marked as spam. Skip these.
if ( ! empty( $comment->is_spam ) ) {
continue;
}
// Add user ID to array.
$user_ids[] = $comment->user_id;
// Check for commentception.
if ( ! empty( $comment->children ) ) {
$user_ids = array_merge( $user_ids, bp_activity_recurse_comments_user_ids( $comment->children ) );
}
}
}
/**
* Filters the list of user IDs for the current activity comment item.
*
* @since BuddyPress 2.1.0
*
* @param array $user_ids Array of user IDs for the current activity comment item.
* @param array $comments Array of comments being checked for user IDs.
*/
return apply_filters( 'bp_activity_recurse_comments_user_ids', $user_ids, $comments );
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 1.7.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.