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

Need to fetch current username in PHP callback method

gginni

Active member
#1
I have created a new page node following below guideline:-

http://xenforo.com/community/threads/editing-templates-and-defining-a-callback-for-pages.7226/

And now I need to fetch current logged-in username in PHP callback method.... Means in PHP callback method having below signature:-

Code:
public static function respond(XenForo_ControllerPublic_Abstract $controller,  XenForo_ControllerResponse_Abstract $response)
        {
I couldn't find any development doc..please let me know how to access current logged-in user user name
 

gginni

Active member
#2
After searching in few files..I got to know that below code is used to get userid:-

Code:
XenForo_Visitor::getUserId();
But how to get username
 

gginni

Active member
#4
I did that myself for first time by looking at other files

Code:
$object = XenForo_Visitor::getInstance();
$username = $object['username'];