Posted on October 1, 2013 , Last Modified on: October 1, 2013
Get the total number of favorites accumulated by a user on his activities
/**
* Get the total no. of favorites accumulated by a user on his activities
* @global type $bp
* @global type $wpdb
* @param int $user_id
* @return int count of total favories by other users on given users activity
*/
function bpdev_count_user_acivity_favs( $user_id ){
global $bp, $wpdb;
$query =$wpdb->prepare("SELECT SUM(meta_value) as total FROM {$bp->activity->table_name_meta} WHERE meta_key = %s AND activity_id IN ( SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d)", 'favorite_count', $user_id );
return (int) $wpdb->get_var( $query );
}
#activity, #bp-hacks