Skip to content

Instantly share code, notes, and snippets.

@KaineLabs
Last active February 29, 2024 10:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaineLabs/fa5e92f3def36621660c120d8bd2dab1 to your computer and use it in GitHub Desktop.
Save KaineLabs/fa5e92f3def36621660c120d8bd2dab1 to your computer and use it in GitHub Desktop.
Change Posts & Comments Statistics to Activities Number & Activities Comments Number
<?php
/**
* Get The User Activities Number.
*/
function yzc_get_user_activities_number( $number, $user_id, $type ) {
if ( $type == 'posts' ) {
global $bp,$wpdb;
$activity_count = $wpdb->get_var( "SELECT COUNT(*) FROM {$bp->activity->table_name}
WHERE component IN ( 'activity', 'groups' ) AND type != 'activity_comment' AND user_id = '$user_id'
");
$total = $number + $activity_count;
}
return $total;
}
add_filter('youzify_get_user_statistic_number', 'yzc_get_user_activities_number', 10, 3 );
/**
* Get The User Activity Comments Number.
*/
function yzc_get_user_activities_comments_number( $number, $user_id, $type ) {
if ( $type != 'comments' ) {
return $number;
}
global $bp,$wpdb;
$total = $wpdb->get_var( "SELECT COUNT(*) FROM {$bp->activity->table_name} WHERE component IN ( 'activity', 'groups' ) AND type = 'activity_comment' AND user_id = '$user_id' ");
return $total;
}
add_filter( 'youzify_get_user_statistic_number', 'yzc_get_user_activities_comments_number', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment