Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Change Activity "All Members" Count to Number of posts.
<?php
/**
* Add Filter.
*/
function yzc_add_all_members_filter() {
add_filter( 'bp_get_total_member_count', 'yzc_change_all_members_posts_number' );
}
add_action( 'bp_before_activity_type_tab_all', 'yzc_add_all_members_filter' );
/**
* Remove Filter.
*/
function yzc_remove_all_members_filter() {
remove_filter( 'bp_get_total_member_count', 'yzc_change_all_members_posts_number' );
}
add_action( 'bp_before_activity_type_tab_groups', 'yzc_remove_all_members_filter' );
/**
* Change Activity "All Members" Number of posts.
**/
function yzc_change_all_members_posts_number( $active_members_count ) {
if ( ! bp_is_activity_directory() ) {
return $active_members_count;
}
return yzc_get_total_activity_posts();
}
/**
* Get User Wall Posts Count.
*/
function yzc_get_total_activity_posts() {
global $bp, $wpdb;
$request = "SELECT COUNT(*) FROM {$bp->activity->table_name} WHERE component = 'activity' AND type != 'activity_comment'";
return $wpdb->get_var( $request );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment