• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

How does login integration work with XenForo?

#1
Hey there,

Soon i well be starting devlopment of an app, and i am currently working on devloping the site for my new fourm. I would love to know how the login integration works with xenforo (the site well not in the /forums/ directory if that helps.

Thanks! :D
 

Daniel Hood

Well-known member
#4
PHP:
$fileDir = './community/';
require ($fileDir . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
XenForo_Application::initialize($fileDir . '/library/', $fileDir);
$request = new Zend_Controller_Request_Http();
$request->setBasePath('/community');
$session = XenForo_Session::startPublicSession($request);
$userModel = XenForo_Model::create('XenForo_Model_User');
$user = $userModel->getUserById($session->get('user_id'));
 
if ($user['user_id'] > 0)
echo "Hello, " . $user['username'];
else
echo "Welcome, Guest!";
// print_r($user);
remove the slashes before print_r to view all possible variables you can access.