View Full Version : How to get userid of members by php?
hienntp
06-06-2016, 08:03 AM
hello,
How to get userid of members by php? I use vbulletin 5.
Thanks!
Replicant
06-06-2016, 02:19 PM
Can you elaborate more on what you are trying to do?
hienntp
06-10-2016, 12:15 AM
I want to get userid of members when logging in forum.
get userid vbulletin 4:
$user = $vbulletin->userinfo;
echo $user['usertid'];
Replicant
06-10-2016, 03:01 AM
The vbulletin object is still available in vb5. The code you show should work.
For getting userid in scripts, this works for me.
$uid=$vbulletin->userinfo['userid'];
echo $uid;
hienntp
06-10-2016, 07:56 AM
I added the code into file account.php
$uid=$vbulletin->userinfo['userid'];
echo $uid;
But error:
Notice: Undefined variable: vbulletin in /var/www/forum.whitehat.vn/Soccer/account.php on line 128
Notice: Trying to get property of non-object in /var/www/forum.whitehat.vn/Soccer/account.php on line 128
Replicant
06-10-2016, 11:43 AM
Account.php is not a core file. You'll need to start up the vbulletin backend to get a result. This example assumes the account.php file is inside your forum root directory. This is a bare bones example.
<?php
require_once('./includes/vb5/autoloader.php');
$vbpath = '.';
vB5_Autoloader::register($vbpath);
vB5_Frontend_Application::init('config.php');
$uid=$vbulletin->userinfo['userid'];
echo $uid;
hienntp
06-10-2016, 12:19 PM
I edit:
require_once('/var/www/forum.whitehat.vn/includes/vb5/autoloader.php');
$vbpath = '.';
vB5_Autoloader::register($vbpath);
vB5_Frontend_Application::init('config.php');
$uid=$vbulletin->userinfo['userid'];
echo $uid;
But error:
Class 'vB5_Frontend_Application' not found
Replicant
06-10-2016, 11:24 PM
Try using your full system path for $vbpath. It's not finding the Class because it's not looking in the right location. Is you account.php file in the /var/www/forum.whitehat.vn directory?
hienntp
06-13-2016, 12:34 AM
I have edit $vbpath = '/var/www/forum.whitehat.vn/.'; and it works.
Thanks!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.