⭐ Alex ⭐
Well-known member
Hey I have a section of my site that needs to get some user properties from the signed in XF user. (Using XF pages for this area is not an option.)
So far I'm using:
The problem is, when the user has been away for long enough, the session they get from this code is a visitor session, and the user has to go back to the forum so that it auto-signs them in, then when they come back to this external page, it finally sees them as logged in.
I found an old thread that used to have working code for XF 1, but I couldn't connect the XF 1 code to the XF 2 counter parts to determine how to accomplish it.
So far I'm using:
PHP:
require('forum/src/XF.php');
XF::start("/");
$app = XF::setupApp('XF\Pub\App');
$session = $app->session();
$user_id = $session->get('userId');
$finder = XF::finder('XF:User');
$user = $finder->where('user_id', $user_id)->fetchOne();
The problem is, when the user has been away for long enough, the session they get from this code is a visitor session, and the user has to go back to the forum so that it auto-signs them in, then when they come back to this external page, it finally sees them as logged in.
I found an old thread that used to have working code for XF 1, but I couldn't connect the XF 1 code to the XF 2 counter parts to determine how to accomplish it.
Using xenforo permission outside of xenforo?
I have, but I think i need to do the inverse.. Call a Xenforo function ( i assume ) to place the logged in user ID into the page_container template. Maybe there is a way to tell xenforo to toss the id into the cookie so the custom php can call it back out?
xenforo.com