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

How to detect a user outside the forum

Discussion in 'XenForo Development Discussions' started by isma, Feb 5, 2014.

  1. isma

    isma Member

    I am still using VB 3.7 although am preparing my new XF.

    When using VB I can detect a user logged in the forum but participating in other sections of my web. For exemple a user can post a comment on an article without logging in again.

    I don't know if I am explaining myself clearly.

    I can do that with these lines of code:

    ----------------------
    include('./global.php');
    include('./includes/functions_user.php');
    $_SESSION["forero"] = $vbulletin->userinfo['username'];
    ----------------------

    Is there a way to do the same in XF?

    Thank you!
     
    Last edited: Feb 5, 2014
  2. Vincent Gabriel

    Vincent Gabriel Active Member

    Can probably do the same thing with this
    http://xenforo.com/community/resources/xenforo-sdk.2790/
     
  3. isma

    isma Member

    Thank you!

    Do you know if it is compatible with XF 1.3?
     
  4. Vincent Gabriel

    Vincent Gabriel Active Member

    Should be yes.
     
  5. isma

    isma Member

    I am trying to print my forum nickname using your application but I must be doing something wrong:

    Code:
    <?php
    require_once('XenForoSDK.php');
    $sdk = new XenForoSDK;
    $loggedIn = $sdk->isLoggedIn();
    if($loggedIn) {
    echo 'Logged In';
    } else {
    echo 'Guest';
    }
    // Get current user
    $user = $sdk->getUser();
    echo $user;
    ?>
    Thank you for your help @Vincent Gabriel
     

Share This Page