TerminalAddict
Active member
in an entirely separate php that I have (test.php) in a folder above my xf installation I have the following code (which I found on this forum):
it always returns 0 (zero) even though I am logged into the forum at /community/
I have also confirmed that the object(XenForo_Visitor) has the following:
can anyone help please?
Code:
<?php
$startTime = microtime(true);
$fileDir = dirname(__FILE__);
$fileDir = $fileDir . '/community';
require($fileDir . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
XenForo_Application::initialize($fileDir . '/library', $fileDir);
XenForo_Application::set('page_start_time', $startTime);
$visitor = XenForo_Visitor::getInstance();
$user_id = $visitor->getUserId();
$username = $visitor->get('username');
$email = $visitor->get('email');
echo "$user_id $username $email";
?>
it always returns 0 (zero) even though I am logged into the forum at /community/
I have also confirmed that the object(XenForo_Visitor) has the following:
Code:
["_user:protected"]=>
array(40) {
["user_id"]=>
int(0)
["username"]=>
string(0) ""