Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Getting a list of users activity count


Boone Gorges
Keymaster

@boonebgorges

Ah, if you only need it once, then it’s easier. Build a list of all members

$query = "SELECT * FROM {$wpdb->users} WHERE spam=0";
$members = $wpdb->get_results( $query, ARRAY_A );

Then loop through $members and do the operation that dre1080 mentions above:

foreach ( $members as $member ) {
$user_id = $member['ID'];

$args = array(
'per_page' => 10000,
'show_hidden' => true,
'user_id' => $user_id
);

if ( bp_has_activities( $args ) ) {
global $activities_template;
$count = $activities_template->total_activity_count;
} else {
$count = 0;
}

echo $user_id . " " . $count . "<br />";

}

I haven’t tested this but it or something very similar to it should print a list on the screen of user ids along side their activity counts.

Skip to toolbar