PDA

View Full Version : pulling user id from outside forums


feras
01-25-2009, 09:37 PM
so, I am looking to create a somewhat small system on my site, that involves the same users in the forums. Basically I want this features 'userbase' to be the same people in the forums.

Now, lets say my site is in the folder:
site

I also have a forums setup at site/forums/
which is where vbulletin is.

I'm trying to write a simple script in site, lets call this test.php, where it will also initialize the same session, and print that users ID if they're already logged into vbulletin.

I know lots about programming, but admit I don't know anywhere near enough about vbulletin, and if I can figure this part out the rest should be easy.

So again my test script is at:
site/test.php

Forums is at:
site/forums/

my test.php script I initially tried was

<?php
require_once('./forums/global.php');
print $vbulletin->session->vars['userid'];
?>


But that was giving me errors from global and init trying to do other includes at other paths that dont exist relevant to this path.

Any help is appreciated :)

Voltar
01-25-2009, 11:22 PM
The last three threads I've looked at had something to do with global.php and not doing a chdir first.

To fix the include path issues, try this:

chdir('/path/to/your/forum/dir/');
require_once('./global.php');

Edit: Also, to fetch/print the userid of the current logged in user (if one is logged in):

$vbulletin->userinfo['userid']

Dismounted
01-26-2009, 04:29 AM
I know lots about programming, but admit I don't know anywhere near enough about vbulletin, and if I can figure this part out the rest should be easy.
The Articles section is a good source of information on programming in vBulletin.

feras
01-27-2009, 11:31 PM
worked like a charm. Thanks