Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter hornets2002

    (@hornets2002)

    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

    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

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show list of users sorted by highest point total’ is closed to new replies.