# nodeinfo/2.2.0/includes/functions.php

NodeInfo(2), version 2.2.0. 33 lines.

- Page: https://pluginprobe.com/plugins/nodeinfo/2.2.0/code/includes/functions.php
- Raw: https://pluginprobe.com/plugins/nodeinfo/2.2.0/raw/includes/functions.php
- Modified: 2023-10-16T15:46:42+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/nodeinfo/2.2.0/code/includes/functions.php#L10-L20`.

```php
<?php
function nodeinfo_get_active_users( $duration = '1 month ago' ) {
	// get all distinct authors that have published a post in the last 30 days
	$posts = get_posts(
		array(
			'post_type'      => 'post',
			'post_status'    => 'publish',
			'orderby'        => 'post_count',
			'order'          => 'DESC',
			'posts_per_page' => 4,
			'date_query'     => array(
				array(
					'after' => $duration,
				),
			),
		)
	);

	if ( ! $posts ) {
		return 0;
	}

	// get all distinct ID from $posts
	return count(
		array_unique(
			wp_list_pluck(
				$posts,
				'post_author'
			)
		)
	);
}

```
