XF 2.2 I want to retrieve the userid & username of the logged in user

I'm creating a blank .php and I would like to know the current user's id & name. I used the addon that was created but it doesn't give me this info. Thanks
 
PHP:
$visitor = \XF::visitor();

$userId = $visitor->user_id;
$username = $visitor->username;

Of course, this needs to be run in the context of the XF application - a blank .php file will not do it, needs to bootstrap the framework first.
 
Back
Top Bottom