Total number of activity update posts by user
-
Hi all,
Attempting to display a TOTAL number of
activity_update
posts that the displayed user has ever posted and echo it in their profile header.This code by Brajesh at BuddDev has been used to do the same for obtaining the total number of favourites on the activities of the user (which can be used in conjunction with
bp_displayed_user_id()
):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 ); }
Is it possible to alter the
$query
line to get theactivity_update
total count instead? Something like:$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)", 'activity_update', $user_id );
(I know the above code is wrong but you get the idea of what i mean).
I’ve also looked at using
<?php echo bp_activity_count( bp_displayed_user_id() ) ?>
but its giving me a result of 0, so I’m not using it right :s .Any pointers appreciated!
- You must be logged in to reply to this topic.