MyBB Community Forums

Full Version: Check if user logged in
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How do I check if user is logged in or not?

If hes offline, it will display login form, if hes online it will display his information, I dont want to use mybb {welcome}, etc since it is not editable.

Thanks
use dedicated templates to accomplish such. You don't need to check separately.
header_welcomeblock_member -> for logged in members
header_welcomeblock_guest -> for those who are not logged in

Use your own contents in those templates as per your requirement.
And how do I edit this bit:

{$lang->welcome_back}

I only want it to say welcome back, Jony, without the date, I just want the date on a different var.

Is there a way to edit it? and could u please get me a list of mybb vars e.g {$lang->welcome_back}, {$username} etc

Thanks
Why you need to edit this? Use specific variables to fetch data,

(2012-11-24, 04:09 PM)jony Wrote: [ -> ]I only want it to say welcome back, Jony, without the date, I just want the date on a different var.

<span>Welcome Back, {$mybb->user['username']}</span>

For date & time:
{$lang->welcome_current_time}

For Most online you can use these variables:
{$recordcount} or {$mostonline['numusers']}
{$recorddate}
{$recordtime}

And for Who's Online you will be able to use:
{$onlinecount}
{$membercount}
{$guestcount}
{$botcount}
{$onlinemembers}

Newest Member:
{$newestmember}

Variable to show unread PM count:
{$mybb->user['pms_unread']}

Variable to show user reputation count:
{$mybb->user['reputation']}

Showing total User & Total Post at Header: (thanx to Yaldaram)

ACP > Templates > Header Templates > header_welcomeblock_member > and find;
{$lang->welcome_pms_usage}
and add the following code just After that;
 | <span style="font-size: 11px;">Total Users: {$stats['numusers']} - Total Posts: {$stats['numposts']}</span>
Save the template.

Now open ./global.php and find;
$plugins->run_hooks("global_start");
and add the following code just Below that;
$stats = $cache->read("stats");
Save the file.

For obtaining available variable list simply create a php file in your MyBB root with the name varlist.php (or something like that) including following code and call the php file in your browser.

<?
    define("IN_MYBB", 1);

    require_once "./global.php";

    echo '<pre>';
    var_dump($mybb);
    var_dump($lang);
    echo '</pre>';
?>
Thank you a lot, but I need the last time visited date, not the current date.
As much I can remember following variable will give you a raw output of last visit, which you have to format further.

{$mybb->user['lastvisit']}

I'll state if I get another one.
It is giving me some random numbers like 1353772598
(2012-11-24, 05:13 PM)jony Wrote: [ -> ]It is giving me some random numbers like 1353772598

Thats not random no. That is unformatted timestamp.

OK, just use this variable and you will get a formatted value:

{$lastvisit}