How does login integration work with XenForo?

Colin Arenburg

New member
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
 
You mean like having a user login on /xenforo/ and then going to your site and having it display their username?
 
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.
 
Top Bottom