1. 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?

Discussion in 'XenForo Development Discussions' started by Colin Arenburg, Nov 25, 2011.

  1. Colin Arenburg

    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
     
  2. Daniel Hood

    Daniel Hood Well-Known Member

    You mean like having a user login on /xenforo/ and then going to your site and having it display their username?
     
  3. Colin Arenburg

    Colin Arenburg New Member

    Yes, but also if not logged in display "blah".
    Thnaks
     
  4. Daniel Hood

    Daniel Hood Well-Known Member

    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.
     
  5. Colin Arenburg

    Colin Arenburg New Member

    Thank you!
     
  6. Daniel Hood

    Daniel Hood Well-Known Member

    No problem. :)
     

Share This Page