Quiver
Active member
Okay, well I thought I had this working but I didn't.
What I want to do is extend this:
So that it also fetches the custom user field (the ID of the field in question is 'banner').
Because, the above addon displays the top poster of the last hour, and that user's homepage.
I want it to also display that user's custom field...which, in this case, happens to be a banner.
What I want to do is extend this:
Code:
<?php
class TwistedPromotion_TopUser_Model_XTopUser extends Xenforo_Model_User
{
public static function TwistedPromotion_TopUserArray() {
$db = XenForo_Application::get('db');
$userModel = XenForo_Model::create('XenForo_Model_User');
$TwistedPromotion_TopUser = array();
$numShown = "1";
$long = "3600";
$TTArray = $db->fetchAll( $db->limit( "SELECT u.username AS username, u.user_id, up.homepage AS homepage, COUNT( * ) AS totalPosts FROM xf_post AS p LEFT JOIN xf_user AS u ON ( u.user_id = p.user_id ) LEFT JOIN xf_user_profile AS up ON ( up.user_id = p.user_id ) WHERE post_date > UNIX_TIMESTAMP()-$long GROUP BY p.user_id ORDER BY totalPosts DESC", $numShown ));
if(sizeof($TTArray) != 0) {
foreach($TTArray as $TTX) {
$TTIds[] = $TTX['user_id'];
}
$userObjs = $userModel->getUsersByIds($TTIds,array());
foreach($TTArray as $TT) {
if ($TT['user_id'])
{
$hrefx = XenForo_Link::buildPublicLink('toposters', $TT);
}
$TwistedPromotion_TopUser[] = array("user" => $userObjs[$TT['user_id']], "username" => $TT['username'], "totalPosts" => $TT['totalPosts'], "homepage" => $TT['homepage']);
}
}
if(count($TwistedPromotion_TopUser))
{
return $TwistedPromotion_TopUser;
}
}
}
Because, the above addon displays the top poster of the last hour, and that user's homepage.
I want it to also display that user's custom field...which, in this case, happens to be a banner.