You can try with below code for layer but to place this in sidebar you may need to create a widget. I havn't tested this code but it should work.
Part Deleted
Or you can check my two plugins and modify according to your need "new-members-widget" and "q2am-recent-questions"
EDIT 1: Added Tested Function To Get All User Data
Check this below function. I have tested it and working completely fine.
function get_user_data()
{
$query = "
SELECT *
FROM ^users, ^userpoints
WHERE ^userpoints.userid = ^users.userid
";
$query_sub = qa_db_query_sub($query);
while ($row = qa_db_read_one_assoc($query_sub, true)):
$this->output(
'<UL>',
'<LI>',
$row['handle'].' has '.$row['points']. ' points',
'</LI>',
'</UL>'
);
endwhile;
}
Getting Below Output
EDIT 2: Added Tested Function To Get Logged In User Data
// This is the query function
function get_user_data()
{
$loggedin_userid = qa_get_logged_in_userid();
$query = "
SELECT *
FROM ^users, ^userpoints
WHERE ^users.userid = $loggedin_userid
AND ^userpoints.userid = $loggedin_userid
LIMIT 1
";
$query_sub = qa_db_query_sub($query);
while ($row = qa_db_read_one_assoc($query_sub, true)):
$this->output(
'<UL>',
'<LI>',
$row['handle'].' has '.$row['points']. ' points',
'</LI>',
'</UL>'
);
endwhile;
}
// Use this where you want to call but make sure if you are using this in widget than you may need to use $themeobject->output instead of $this->output
if (qa_is_logged_in())
$this->get_user_data();
EDIT 3: TO Display Only Usename and Points Use This
$userhandle = qa_get_logged_in_handle();
$userpoints = qa_get_logged_in_points();
$this->output($userhandle . ' ' .$userpoints);