Every other forum script that we have on this planet displays the post count just below the user’s avatar but bbPress is different. Forums were build to interact and not inflate post counts but sometime I feel the need to have it when the users are not tech savvy and like to have loads of features.
ck already has a plugin for this which goes by the name of Post count Plus. It also has loads of other options. the plugin is great as it caches the post counts else every post would have generated queries to determine the post count which would have affect the performance severely.
I am not much of a show off person when it comes to performance but not having it on the forums at all itches my hand to do something. Another good place to show the user’s post count can be the profile but I learned that its not possible to add data to the profile page as the function bb_profile_data doesn’t have an action hook. It was reported a long way back (Trac Ticket #784) but still its on the pending list.
Meanwhile CK posted mysql queries to post the posts and topics started count which works for the default bbPress table prefix. And i change it to adapt the variable which take care of all the installations.
<?php bb_profile_data(); ?>
with the following code
<?php bb_profile_data(); ?> <div id="user-stats"> <?php global $bb_table_prefix; $query1 = "SELECT COUNT(*) FROM ".$bb_table_prefix."posts WHERE poster_id = $user_id AND post_status = 0"; $query2 = "SELECT COUNT(*) FROM ".$bb_table_prefix."posts WHERE poster_id = $user_id AND post_status = 0 AND post_position = 1"; echo "Forum Posts: <b>".$bbdb->get_var($query1)."</b> "; echo " Topics Started: <b>".$bbdb->get_var($query2)."</b>"; ?> </div>
Now you can style is using the DIV ID user-stats via CSS. And don't use these queries somewhere else it would cause performance penalties. Have your say in the comments and let me know if I can be of some help.