bp_activity_recurse_comments_user_ids

Recurse through all activity comments and collect the IDs of the users who wrote them.

Description

(array) bp_activity_recurse_comments_user_ids( (array) array $comments = array() ); 

Returns (array)

Array of user IDs.

Parameters (1)

0. $comments — Optional. (array) => array $comments = array()
The comments.

Usage

  1. if ( !function_exists( 'bp_activity_recurse_comments_user_ids' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-template.php'; 
  3.  
  4. // The comments. 
  5. $comments = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_activity_recurse_comments_user_ids($comments); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-activity/bp-activity-template.php  
  1. function bp_activity_recurse_comments_user_ids( array $comments = array() ) { 
  2.  
  3. // Default user ID's array. 
  4. $user_ids = array(); 
  5.  
  6. // Loop through comments and try to get user ID's. 
  7. if ( ! empty( $comments ) ) { 
  8. foreach ( $comments as $comment ) { 
  9.  
  10. // If a user is a spammer, their activity items will have been 
  11. // automatically marked as spam. Skip these. 
  12. if ( ! empty( $comment->is_spam ) ) { 
  13. continue; 
  14.  
  15. // Add user ID to array. 
  16. $user_ids[] = $comment->user_id; 
  17.  
  18. // Check for commentception. 
  19. if ( ! empty( $comment->children ) ) { 
  20. $user_ids = array_merge( $user_ids, bp_activity_recurse_comments_user_ids( $comment->children ) ); 
  21.  
  22. /** 
  23. * Filters the list of user IDs for the current activity comment item. 
  24. * @since 2.1.0 
  25. * @param array $user_ids Array of user IDs for the current activity comment item. 
  26. * @param array $comments Array of comments being checked for user IDs. 
  27. */ 
  28. return apply_filters( 'bp_activity_recurse_comments_user_ids', $user_ids, $comments );