• Resolved wbxpress

    (@wbxpress)


    hello,

    i would like to use this plugin as a reputation system based on total contribution to the forum in percentage.

    users contribution = (posts by user) / (total posts of the forum) * 100%

    can u please help me in this regard?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Robin W

    (@robin-w)

    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.www.ads-software.com/plugins/code-snippets/

    Thread Starter wbxpress

    (@wbxpress)

    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 3 years, 6 months ago by wbxpress.
    Thread Starter wbxpress

    (@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 3 years, 6 months ago by wbxpress.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Reputation Point based on Total Posts’ is closed to new replies.