Last active
February 29, 2024 10:29
-
-
Save KaineLabs/fa5e92f3def36621660c120d8bd2dab1 to your computer and use it in GitHub Desktop.
Change Posts & Comments Statistics to Activities Number & Activities Comments Number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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