PDA

View Full Version : vB Auth system


Paul K
05-22-2010, 01:31 PM
Hello all,

I'm using only the forum and all but I want to use the vB user system on the rest off my website as well. How can I use vB if a user is logged on and what his user name is?

Thanks!

AfterWorldForum
05-23-2010, 04:24 PM
Hey,

We do something similar to this on our site (albeit that runs on vB 3.8.*).

The first thing you do is add an include to the vB global.php (Assuming your file is in the forumroot folder):


require_once("./global.php");


This allows you to tap into the back-end system of vBulletin, which includes their access to the database, and a variety of useful objects. With that done, you can verify a user is logged in:


if (!$vbulletin->userinfo['userid'])
{
print_no_permission();
}


And to deduct their username, use


$vbulletin->userinfo['username']

(Note: I did not verify the last line. If it does not work, create a blank php file, add the include from above, and have php spit out the full contents of the $vbuletin->userinfo array. Chances are that gives you a better idea).

HTH.

Peter

ragtek
05-27-2010, 08:38 PM
You can also include only the init.php (if you need only the userdata). It's a little bit faster

Paul K
06-12-2010, 02:28 PM
For any others that still want to know how I did this: used the code of init.php, while removing lots of unneeded stuff like the hooks loading etc, and for vB for this is the username:
$vbulletin->datastore->registry->userinfo['username'];