Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not Solved display a username in header
#1
Not Solved
hi
how do i retrieve the username and post count and show it in the header

kenny
#2
Not Solved
Use this variable for username:
{$mybb->user['username']}

For post counts of the user:
{$mybb->user['postnum']}
#3
Not Solved
sorry should have said a specific user
#4
Not Solved
Which user? How do you plan to choose such user?
Soporte en Español

[Image: signature.png]

Discord at omar.gonzalez (Omar G.#6117); Telegram at @omarugc;
#5
Not Solved
i know the user i want to display and it will not change i also want to show the users last visit and post count

example

bob 17/10/2012 39 posts
#6
Not Solved
Something like this?

<?php
define("IN_MYBB", 1);
require ('global.php'); // be sure that u r running this php-code in the same
// directory of global.php, or else change the path.
$user = get_user(SPECIFIC_UID);
$name = $user['username'];
// grab other info in same pattern
?>
<?echo $name?>
#7
Not Solved
You probably can use something like Template Conditionals. header template:
<setvar user>get_user('USERID')</setvar>
<if $tplvars['user']['uid'] then>
Username: <func htmlspecialchars_uni>$tplvars['user']['username']</func>
Post Count: <?=my_number_format($tplvars['user'][''postnum''])?>
</if>

But, if the desired information is not supposed to be frequently changed, then probably using some kind of cache method, or even static information could be better when it comes to performance.
Soporte en Español

[Image: signature.png]

Discord at omar.gonzalez (Omar G.#6117); Telegram at @omarugc;
#8
Not Solved
I guess you will have to get the data from the database...
You probably will need a plugin, since, AFAIK, we can't use PHP in templates
It will be a simple plugin though, just to grab the data from the database and display it in the header.
[Image: PHgwI.png]


Forum Jump:


Users browsing this thread: 1 Guest(s)