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

Unmaintained XenForo Connector 1.0

Integrate XF data on your website

  1. Benjy
    Hi,

    Well, 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 $config['cookie']['domain'] and $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 URL
    echo XenForo_Link::buildPublicLink('canonical:threads/add-reply'$thread); // add reply URL

Recent Reviews

  1. dknife
    dknife
    5/5,
    Version: 1.0
    Just built my new revision of my website and wanted to use XenForo as my member and authentication/session platform along with the forums. This connector has worked great for incorporating necessary components into my site.
  2. Justin Kringstad
    Justin Kringstad
    5/5,
    Version: 1.0
    very helpful