HI,
Thank you for the question.There does not exist a function in BuddyPress API to achieve this currently.
We can create own own like this
/** * Returns total activities count for the user * * @param int $user_id user id. * @param string $type activity type. * * @return int */ function buddydev_get_total_user_activities_count( $user_id, $type = '' ) { global $wpdb; $table = buddypress()->activity->table_name; $where_conditions = array(); $where_conditions[] = $wpdb->prepare( 'user_id = %d', $user_id ); if ( $type ) { $where_conditions[] = $wpdb->prepare( "type = %s", $type ); } $whe_sql = join( ' AND ', $where_conditions ); return absint( $wpdb->get_var( "SELECT count(DISTINCT id) FROM {$table} WHERE {$whe_sql}" ) ); }
and use it like
$updates_count = buddydev_get_total_user_activities_count( 1, 'activity_update' ); $all_count = buddydev_get_total_user_activities_count(1)
and so on.
Regards
BrajeshYou need to print that using echo.
Example:-
echo "Count:" . buddydev_get_total_user_activities_count( 1, 'activity_update' );
Where 1 is user id.
Viewing 6 posts - 1 through 6 (of 6 total)
The topic ‘How get I get the total activity count of a user’ is closed to new replies.
This topic is: not resolved