Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Total number of activity update posts by user

@danbp

Participant

You can use BuddyPress Member Stats plugin or just this function (in bp-custom.php)

This example is for group updates only. But you have the general idea. And please, keep calm, if you have a big update writers community, totalizing ALL existing updates can became a mess and a real problem which can slow down a site. You’re warned ! 😉

function bms_get_total_group_updates_count(){
global $wpdb, $bp;
$user_id = bp_displayed_user_id(); 

	if ( bp_is_active( 'groups' ) ) :

	// DB query 
	$total_updates = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}bp_activity 
			WHERE component = 'groups' 
			AND   type = 'activity_update'
			AND   user_id = '%s' ", $user_id ) );
									  
	echo $total_updates;

	endif;
}

And for the output somewhere in your template, something like:

<li><?php _e( 'My updates:', 'buddymemberstats' ); ?>&nbsp;<?php bms_get_total_group_updates_count(); ?></li>

Yes, i’m the plugin author. 😉

Skip to toolbar