Skip to:
Content
Pages
Categories
Search
Top
Bottom

User ranking system?


  • jenseo
    Participant

    @jenseo

    Hi!

    I’m looking for a solution to the following:

    I would like to display a user ranking system based on the number of posts they have written in the forums.

    Take a look at the reputation indicator under the users profile photo on this forum to see what I’m looking for:

    User reputation under profile picture.

    Any ideas on how I can achieve this?

    Thanks!

    // Jens.

Viewing 25 replies - 1 through 25 (of 29 total)

  • Robin W
    Moderator

    @robin-w

    Yes, but depends on how code savvy you are.

    Basically adding this to your functions file will get a count showing

    function display_counts () 
    {
    		$post_count = bbp_get_user_post_count( bbp_get_reply_author_id( $reply_id )) ;
    		echo "<br>Total posts : " ;
    		echo $post_count ;
    		echo "</br>" ;
    		//add some if statements here eg if $post_count>100 echo 'hero' or a link to a picture
    		}
    add_action ('bbp_theme_after_reply_author_details', 'display_counts') ;
    
    

    and where I’ve indicated adding some if statements link to icons or words will do the second


    jenseo
    Participant

    @jenseo

    Awesome Robin, just what I need! Will try it out tonight!

    Thanks alot!

    // Jens.


    jenseo
    Participant

    @jenseo

    Hmm, I’m not getting any count back, it just says Posts: 0


    Robin W
    Moderator

    @robin-w

    yes just tried it, and it does say 0 – will come back to you – I just cribbed some code within a larger file that it worked several months ago – will take a closer look !


    jenseo
    Participant

    @jenseo

    Thanks Robin, I really appreciate it!
    // Jens.


    Robin W
    Moderator

    @robin-w

    Ok, not quite sure why that stopped working – it used to !

    But have just tested this :

    function display_counts () 
    {
    		
    		$user_id=bbp_get_reply_author_id( $reply_id ) ;
    		$topics  = bbp_get_user_topic_count_raw( $user_id);
    		$replies = bbp_get_user_reply_count_raw( $user_id);
    		$post_count   = (int) $topics + $replies;
    		echo "<br>Total posts : " ;
    		echo $post_count ;
    		echo "</br>" ;
    		}
    add_action ('bbp_theme_after_reply_author_details', 'display_counts') ;

    and that works.

    As before you can then add some if statements to display a status or icon


    jenseo
    Participant

    @jenseo

    Works like a charm Robin, thank you so much!

    // Jens.


    Robin W
    Moderator

    @robin-w

    Great, glad you’re fixed.

    If you do some coding for ranking, can you post this back here, and maybe I’ll add it as a plugin for others benefit


    jenseo
    Participant

    @jenseo

    Of course, no problem!

    // Jens.


    Stagger Lee
    Participant

    @stagger-lee

    @Robin, can you give some example for this, inside this code above:

    //add some if statements here eg if $post_count>100 echo ‘hero’ or a link to a picture

    No matter what I tried it doesnt work.


    Robin W
    Moderator

    @robin-w

    something like

    function display_counts () {
    		
    		$user_id=bbp_get_reply_author_id( $reply_id ) ;
    		$topics  = bbp_get_user_topic_count_raw( $user_id);
    		$replies = bbp_get_user_reply_count_raw( $user_id);
    		$post_count   = (int) $topics + $replies;
    			if ($post_count >100) { 
    			echo '<br>Hero' ;
    			echo "</br>" ;
    			}
    			else {	
    			echo "<br>Total posts : " ;
    			echo $post_count ;
    			echo "</br>" ;
    			}
    		}
    add_action ('bbp_theme_after_reply_author_details', 'display_counts') ;

    Stagger Lee
    Participant

    @stagger-lee

    Thanks. Got it to work, seems I missed one symbol.


    Robin W
    Moderator

    @robin-w

    great – glad you’re fixed !


    Pushkar Kathayat
    Participant

    @pushkarsingh32

    I also want to use user rating system in one of my blog. Can Janseo please would you like to provide the final code for the same?


    Stagger Lee
    Participant

    @stagger-lee

    I did not ooked for User ranking/Voting system. I needed simple star systems for posts count. If User has so many posts/comments give him/her one additional star (under avatar).

    So here is my code. Maybe it could be reduced in lines, made better. I have brain blocade right now.

    // bbPress User post count
    function display_counts () 
    {
    		
    		$user_id=bbp_get_reply_author_id( $reply_id ) ;
    		$topics  = bbp_get_user_topic_count_raw( $user_id);
    		$replies = bbp_get_user_reply_count_raw( $user_id);
    		$post_count   = (int) $topics + $replies;
    		echo "<div class=\"user-comments-count\">" ;
    		echo "<strong>" . "Comments: " . "</strong>" ;
    		echo $post_count ;
    		echo "</div>" ;
    		// echo "</br>" ;
    		//if ($post_count > 1) {
    //	    echo '<i class="svg-icon all-stars"></i>'; 
    //	    }
    		
    		if ($post_count >= 1 && $post_count <= 20) {
    		echo '<div class="all-stars"><i class="svg-icon one-star"></i></div>'; 
    		}
    		elseif($post_count >= 21 && $post_count <= 50) {
    		echo '<div class="all-stars"><i class="svg-icon two-star"></i></div>';
    		}
    		elseif($post_count >= 51 && $post_count <= 100) {
    		echo '<div class="all-stars"><i class="svg-icon three-star"></i></div>';
    		}
    		elseif($post_count >= 101 && $post_count <= 500) {
    		echo '<div class="all-stars"><i class="svg-icon four-star"></i></div>';
    		}
    		elseif($post_count >= 501 && $post_count <= 1000) {
    		echo '<div class="all-stars"><i class="svg-icon five-star"></i></div>'; 
    		}
    		elseif($post_count >= 1001 && $post_count <= 2000) {
    		echo '<div class="all-stars"><i class="svg-icon six-star"></i></div>';
    		}
    		elseif($post_count >= 2001 && $post_count <= 5000) {
    		echo '<div class="all-stars"><i class="svg-icon seven-star"></i></div>';
    		}
    		elseif($post_count >= 5001 && $post_count <= 10000) {
    		echo '<div class="all-stars"><i class="svg-icon eight-star"></i></div>';
    		}
    		elseif($post_count >= 10001 && $post_count <= 50000) {
    		echo '<div class="all-stars"><i class="svg-icon nine-star"></i></div>';
    		}
    		echo "</br>" ;
    		}
    add_action ('bbp_theme_after_reply_author_details', 'display_counts');

    CSS, needed for this snippet:

    .svg-icon,
    .all-stars {
      font-family: 'Your SVG Web Font';
      font-style: normal;
      font-weight: normal;
      text-decoration: inherit;
      text-align: center;
      text-transform: none;
      width: 1em;
      }
      
    .one-star:before,
    .two-star:before,
    .three-star:before,
    .four-star:before,
    .five-star:before,
    .six-star:before,
    .seven-star:before,
    .eight-star:before,
    .nine-star:before,
    .all-stars:before {
      left: 12px;
      position: absolute;
    }
    
    .one-star:before {
      content: '\28b';
    }
    .two-star:before {
      content: '\28b''\28b';
    }
    .three-star:before {
      content: '\28b''\28b''\28b';
    }
    .four-star:before {
      content: '\28b''\28b''\28b''\28b';
    }
    .five-star:before {
      content: '\28b''\28b''\28b''\28b''\28b';
    }
    .six-star:before {
      content: '\28b''\28b''\28b''\28b''\28b''\28b';
    }
    .seven-star:before {
      content: '\28b''\28b''\28b''\28b''\28b''\28b''\28b';
    }
    .eight-star:before {
      content: '\28b''\28b''\28b''\28b''\28b''\28b''\28b''\28b';
    }
    .nine-star:before {
      content: '\28b''\28b''\28b''\28b''\28b''\28b''\28b''\28b''\28b';
    }
    
    .all-stars:before {
      content: '\28b''\28b''\28b''\28b''\28b''\28b''\28b''\28b''\28b';
      color:#ddd;
    }

    Stagger Lee
    Participant

    @stagger-lee

    I accidentally wrote class six as one censored word here.
    Common people, can you not write word seeeeeeeeex here. 🙂

    Put censored list online for view, bots dont read it.


    Stagger Lee
    Participant

    @stagger-lee

    Forgot this, very important. Cannot test it now, dont have so huge forum. And dont want to touch database just to test.

    For Users with over 50.000 posts and up to infinite:

    elseif($post_count >= 50001) {
    echo '<div class="all-stars"><i class="svg-icon nine-star"></i></div>';
    }

    Robin W
    Moderator

    @robin-w

    I have just released a plugin for user ranking

    https://wordpress.org/plugins/bbp-user-ranking/


    maxvdbiezen
    Participant

    @maxvdbiezen

    Hi Robin,

    I installed your plugin and it works great! Is there a way to get an overview of users for each rank? I want to know when users promote to a higher rank.

    Max


    Robin W
    Moderator

    @robin-w

    let me take a look at how easy that is to do


    Robin W
    Moderator

    @robin-w

    user management info now done in version 2.4 !


    Robin W
    Moderator

    @robin-w

    I can’t directly tell you when a user moves ranks, as the system works on counting topics and replies as it displays, rather than storing data against each user.


    maxvdbiezen
    Participant

    @maxvdbiezen

    Hi Robin,

    Thanks for the quick update! I think this is a very useful addition to the plugin.

    Max


    Robin W
    Moderator

    @robin-w

    great – thanks for the suggestion in the first place


    chandra08
    Participant

    @chandra08

    Hello @robin-w,

    I used your plugin => bbp user ranking , and working very great and very helpful.
    The plugin rank user by reply+create topic = ranking. But can you help me make features to count based on topic tag and make star ranking?

    Example:
    Topic created: 10
    Reply : 20

    topic tag1 ***
    topic tag2 ****
    topic tag3 **

    Thank You!

Viewing 25 replies - 1 through 25 (of 29 total)
  • You must be logged in to reply to this topic.
Skip to toolbar