Example #1
0
/**
 * Recurse through all activity comments and collect the IDs of the users who wrote them.
 *
 * @since BuddyPress (1.7)
 *
 * @param array $comments Array of {@link BP_Activity_Activity} items.
 * @return array Array of user IDs.
 */
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));
            }
        }
    }
    // Filter and return
    return apply_filters('bp_activity_recurse_comments_user_ids', $user_ids, $comments);
}
/**
 * Recurse through all activity comments and collect the IDs of the users who wrote them.
 *
 * @since BuddyPress (1.7.0)
 *
 * @param array $comments Array of {@link BP_Activity_Activity} items.
 * @return array Array of user IDs.
 */
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);
}
/**
 * Recurse through all activity comments and collect the IDs of the users who wrote them.
 *
 * @since BuddyPress (1.7)
 *
 * @param array $comments Array of {@link BP_Activity_Activity} items.
 * @return array Array of user IDs.
 */
function bp_activity_recurse_comments_user_ids(array $comments)
{
    $user_ids = array();
    foreach ($comments as $comment) {
        // If a user is a spammer, their activity items will have been automatically marked as spam. Skip these.
        if ($comment->is_spam) {
            continue;
        }
        $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));
        }
    }
    return $user_ids;
}