@jcandothers
14 years, 6 months ago
Couldn’t find anything on this so I wrote something. It seems to work for me. I simply add this to the bp-custom.php
function update_friends_count( $user_id ) { global $wpdb, $bp; if ($friend_ids = BP_Friends_Friendship::search_friends( ”, $user_id )) { foreach ($friend_ids AS $fid) { $total_sql = “SELECT COUNT(id) FROM {$bp->friends->table_name} WHERE initiator_user_id = $fid OR friend_user_id = $fid”; $total_friend_ids = $wpdb->get_var($total_sql); update_usermeta($fid, ‘total_friend_count’, (int)($total_friend_ids) – 1); } } do_action( ‘update_friends_count’, $user_id ); } add_action( ‘wpmu_delete_user’, ‘update_friends_count’, 1 ); add_action( ‘delete_user’, ‘update_friends_count’, 1 ); add_action( ‘make_spam_user’, ‘update_friends_count’, 1 );