If you are unsure, use the following if you hook in profiles:
$user = get_user($memprofile['uid']);
$user['postnum'];
$user['reputation'];
$user['referrals'];
Sorry I have tried both:
$user = get_user($memprofile['uid']);
$user = get_user($mybb->user['uid']);
I think it needs a query!
$user = get_user($mybb->user['uid']) is the exact equal to $mybb->user. Print_r the $mybb->user object.
Man this is harder than I thought.
OK I am gonna go straight to the point here. I would like to return:
['postnum']
['reputation']
['referrals']
Globally or at least in
postbit and
user profile.
I have this hooked to
global_start but it will generate 1 query each time which is no go for me.
$query = $db->query("
SELECT u.postnum, u.reputation, u.referrals, u.uid
FROM ".TABLE_PREFIX."users u
WHERE u.uid = ".intval($mybb->input['uid'])."
");
while ($row = $db->fetch_array($query)) {
$mybb->custompostnum = $row['postnum'];
$mybb->customreputation = $row['reputation'];
$mybb->customreferrals = $row['referrals'];
}
}
Holy Cow just nailed it wow thanks yo very much
$user = get_user($mybb->input['uid']);
$mybb->postnum = $user['postnum'];
$mybb->reputation = $user['reputation'];
$mybb->referrals = $user['referrals'];
Print_r the $mybb->user object and see what variables are available (3rd time).
echo "<pre>";
print_r($mybb->user);
echo "</pre>";
exit;
get_user($uid) already runs a query if the target user is not present in the cache.
@Shade thanks very much sorry not familiar with that PHP value. But it appears I found the way. Check the 14th reply.
Wait wait wait. Why are you wasting memory by declaring other properties for the $mybb object? It doesn't make any sense.
Also, all the parameters you are requesting are already available (4th time) in the $mybb->user object. If you print_r'd it, you'd see that $mybb->user['referrals'], $mybb->user['postnum'] and $mybb->user['reputation'] are available. Learn to read.
$mybb->user['postnum'] shows mine (user logged-in) post count. I mean it will show my postcount on each and every profile!!!!!!!!!!!
I want each user profile (based on user UID) to show its equivalent data.
Then why are you hooking into global_start? You must hook somewhere else.
You should be hooking into postbit and member_profile_end (or start). You shouldn't need to run a query at all, since all of those values that you want are already defined in those functions.