Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
3.0k views
in Plugins by

For the newest-users-plugin I would like to display the users as it is in top scoring users list with points and two columns.

Therefore I looked into qa-page-users.php and tried to adopt the code for the plugin as:

    $start=qa_get_start();    
    $pagesize=50; // how many users to display // qa_opt('page_size_users');
    $userArrayQuery = array(
        'columns' => array('^users.userid', 'created', 'handle', 'points', 'flags', '^users.email', 'avatarblobid', 'avatarwidth', 'avatarheight'),
        'source' => '^users JOIN (SELECT userid FROM ^userpoints ORDER BY points DESC LIMIT #,#) y ON ^users.userid=y.userid JOIN ^userpoints ON ^users.userid=^userpoints.userid',
        'arguments' => array($start, $pagesize),
        'arraykey' => 'userid',
        'sortdesc' => 'created',
    );
    $users=qa_db_select_with_pending($userArrayQuery);


However, specifying sortdesc => created it is not ordering the list correctly!

1 Answer

0 votes
by

Okay, it is working now I modified the query like that (removing LIMIT and arguments):

    $userArrayQuery = array(
        'columns' => array('^users.userid', 'created', 'handle', 'points', 'flags', '^users.email', 'avatarblobid', 'avatarwidth', 'avatarheight'),
        'source' => '^users JOIN (SELECT userid FROM ^userpoints ORDER BY points DESC) y ON ^users.userid=y.userid JOIN ^userpoints ON ^users.userid=^userpoints.userid',
        'arraykey' => 'userid',
        'sortdesc' => 'created',
    );

 

...