WordPress.org

Ready to get started?Download WordPress

Forums

BuddyPress Rate Forum Posts
[resolved] Show list of users sorted by highest point total (3 posts)

  1. hornets2002
    Member
    Posted 1 year ago #

    How can I show a complete list of users and their points?

    http://wordpress.org/extend/plugins/buddypress-rate-forum-posts/

  2. hornets2002
    Member
    Posted 1 year ago #

    Nevermind :-) I have figured this out by using

    global $wpdb;
    $topuser = array();
    $html = "";	
    
    // query points by each user
    $users = $wpdb->get_results("SELECT ID FROM $wpdb->users ORDER BY ID");
    foreach ( $users as $user ) {
            $views = get_user_meta( $user->ID, 'rfp_post_karma', 1 );
        $topuser[] = array( 'id' => $user->ID, 'views' => $views);
        wp_reset_query();
    }
    
    // function to sort array based on views count
    function sortViews($a, $b) {
        return $b['views'] - $a['views'];
    }
    usort($topuser, 'sortViews'); // sort the array
  3. stickFinger
    Member
    Posted 1 year ago #

    hey hornets2002

    Would you mind to tell me where did you put your code and how did you pull the results (eg. widget?)

    As you can see here http://wordpress.org/support/topic/widget-and-possible-bbpress?replies=2 i´d like to use this on a project.

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags