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

[Free Add-on ] XenForo Connector 1.0

No permission to download
XenForo Connector
About
This is more copy/paste code than a resource, but the forum is being archived and as I'm getting some emails about the old forumConnector, here it is for everyone to find conveniently.

This is designed to be copied/pasted into a PHP script on your website and requires XenForo to be installed on the same fileserver. If your website and your forums don't use the same subdomain (or more generally if you have cookie issues), be sure to set your
Code:
$config['cookie']['domain']
and
Code:
$config['cookie']['path']
(in your forums/library/config.php file).
PHP:
define('XF_ROOT', '/my/path/to/xf'); // set this (absolute path)!define('TIMENOW', time());define('SESSION_BYPASS', false); // if true: logged in user info and sessions are not needed
 require_once(XF_ROOT . '/library/XenForo/Autoloader.php');
 XenForo_Autoloader::getInstance()->setupAutoloader(XF_ROOT . '/library');
 XenForo_Application::initialize(XF_ROOT . '/library', XF_ROOT);XenForo_Application::set('page_start_time', TIMENOW);XenForo_Application::disablePhpErrorHandler();XenForo_Application::setDebugMode(false);
 
if (!SESSION_BYPASS)
{XenForo_Session::startPublicSession();
 $visitor = XenForo_Visitor::getInstance();
 
 if ($visitor->getUserId())
 {$userModel = XenForo_Model::create('XenForo_Model_User');$userinfo = $userModel->getFullUserById($visitor->getUserId());
 }
}
 restore_error_handler();restore_exception_handler();
And here are some useful bits of code ;)

Get the logout URL
PHP:
$visitor = XenForo_Visitor::getInstance(); // this could be moved to the "main" code above, right after the $userinfo initialization
 echo XenForo_Link::buildPublicLink("canonical:logout", $userinfo, array('_xfToken' => $visitor['csrf_token_page'], 'redirect' => 'any_url')); //redirect is optional
Get a thread's info and URL
PHP:
$threadModel = XenForo_Model::create('XenForo_Model_Thread');$thread = $threadModel->getThreadById(ID); // thread info (associative array)
 echo XenForo_Link::buildPublicLink('canonical:threads', $thread); // thread URLecho XenForo_Link::buildPublicLink('canonical:threads/add-reply', $thread); // add reply URL
Author
Caldexi
Downloads
2
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from Caldexi