get username logged in help

i want to get the logged in user and past it in to this simple line of code
where "username" is the logged in user ;)
if(!isset($user)) $user = "username";
would it be possible to get custom profile "lines" or "bars" not sure what i shall call it, but you know, like "Location:"

Jake Bunce

XenForo moderator
Staff member
In your PHP code you can use this to access the username of the logged in user:

$visitor = XenForo_Visitor::getInstance();
$user = $visitor['username'];