XenForo Nulled Community

Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

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

Get user_id of visitor

XenForo Rocks

Team Member
Administrator
Moderator
+Lifetime VIP+
Contributor
ViP
True Member
Suppliers
Registered
#1
XenForo Rocks submitted a new resource:

Get user_id of visitor - Get Visitor user_id in xenforo 2.0

In XenForo 1, getting the user_id involved the getInstance and getUserId methods.

Code:
$user_id =XenForo_Visitor::getInstance()->getUserId();
In XenForo 2, it's a matter of using visitor().

Code:
$visitor = \XF::visitor();
 
$user_id = $visitor['user_id'];
Once the user_id is known then the $user information is available.

Code:
$finder = \XF::finder('XF:User');
$user = $finder->where('user_id', 1)->fetchOne();
 
\XF::dump($user);
Read more about this resource...
 

Similar threads

Similar threads