XF 2.2 Pulling the username of the user viewing a page?


Well-known member
Is there a code snippet that'll pull the username of the person viewing a page within Xenforo?

Eg: If I have a dashboard page for something, and let's say UserX is viewing said page, can I put a string in that would say

"Hello, UserX."

and the username be a link to their profile? is this a possibility?


XenForo moderator
Staff member
<a href="{{ link('members', $xf.visitor) }}">Click here</a>

Depending on where you plan to use it, you may want to add a conditional for guests as guests don't have profiles.