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

How to get the User ID in Route Handling Files

robdog

Well-known member
#1
PHP:
class CLASS_NAME implements XenForo_Route_Interface, XenForo_Route_BuilderInterface
{
    public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
    {
        $visitor = XenForo_Visitor::getInstance();
        print_r($visitor);
    }
}
Visitor is always returning a NON-logged in user.(yes I am logged in) What am I missing?

Thanks.
 

robdog

Well-known member
#2
Sorry to bump my own thread, but still trying to figure this out. Basically want the same route handler to render the page differently if they user is logged in or not.
 

Jake Bunce

XenForo moderator
Staff member
#3
I just tested this. It appears the visitor object is not yet built at this point in the execution. You will have to do the check elsewhere, such as in the controller action.