try this
add_action ('bbp_theme_after_reply_author_details', 'display_user_percentage') ;
function display_user_percentage ($reply_id = 0) {
$user_id=bbp_get_reply_author_id( $reply_id ) ;
$topic_count = bbp_get_user_topic_count_raw( $user_id);
$reply_count = bbp_get_user_reply_count_raw( $user_id);
$post_count = (int) $topic_count + $reply_count;
$stats = bbp_get_statistics();
$total_posts = $stats['topic_count'] + $stats['reply_count'] ;
$percentage = $post_count/$total_posts*100 ;
echo '<div class="tc_display">' ;
echo '<ul>' ;
echo '<li>' ;
echo 'User Contribution : ' ;
echo round($percentage, 2) ;
echo '%' ;
echo "</li>" ;
echo "</ul>" ;
echo "</div>" ;
}
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
https://en-gb.ww.wp.xz.cn/plugins/code-snippets/
Thank you so much for providing me the code. It is working nice in localhost platform. But in live site the percentage calculation is erroneous. (few user’s contribution more than 2000%).
https://wbxpress.com/forums/
-
This reply was modified 5 years ago by
wbxpress.
I have migrated to bbpress from other forum forum software. after migration I lost many user’s details. As a result, Anonymous users are there in my present forum. Anonymous user (deleted user) with many many topics and posts. that’s why, i think the calculation is erroneous.
https://wbxpress.com/files/2021/05/reputation.jpg
-
This reply was modified 5 years ago by
wbxpress.