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 Description


Parameters Parameters

$comments

(Optional) Array of BP_Activity_Activity items.

Default value: array()


Top ↑

Return Return

(array) Array of user IDs.


Top ↑

Source 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 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 );
	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.7.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.