Log in

View Full Version : Problems with: $vbulletin->userinfo['userid'];


cashaddy
12-21-2008, 11:30 AM
Hey mates,

got a small problem, which is already transformed to a major one...

i want to add a login box to my wordpress frontend, and if the user is logged in to the forum it should display a welcome message and some related stuff...

main facts:

i am including the global.php while using this code (added it to the header.php in wordpress. that it's openend on every page):

if (!file_exists('/path/forum/global.php')) { echo "++++ IT!";
exit; }

require_once('/path/forum/global.php');


got that code in my sidebar:

$userid=$vbulletin->userinfo['userid'];
echo '"'.$userid.'"';

the result i get: "" => that means, i can't read the userid of a logged in user.

got any tipps? would be pretty happy if yes :D

Deceptor
12-21-2008, 11:33 AM
Where is your wordpress script in relation to your forum? The issue will be the cookies on your forum won't also be on the wordpress site.

You could probably fix this by setting the vb cookie path to /.

cashaddy
12-21-2008, 11:41 AM
wordpress installation is located in : domainname.de/
vb installation is located in: domainname.de/forum

i have already set the cookiepath to /
i also set the cookiedomain to .domainname.de

i think i will get insane soon :D

Deceptor
12-21-2008, 11:43 AM
Well I know my test forum is on /test/, I can access the vB cookies on the main part of my site which is in a folder up from test/. I only have cookie path to set /, no cookie domain setting.

Try logging out of your vB forum, then back in so vB re-makes the cookies for you :)

cashaddy
12-21-2008, 12:08 PM
haha, i just uploaded a test.php which includes my code to the /forum directory, and. guess what. it's working. ...

i don't know why, but it don't want to work in the "/" directory...

if i am testing it without wordpress (simply using the test.php, stand alone file) it says, that the paths inside of the global.php are not correctly anymore.

i would have to add the /forum/ path inside of the global.php to all file-paths. like for the /includes/init.php ... otherwise it won't work - i think.

Deceptor
12-21-2008, 12:09 PM
Perhaps try:
chdir('/path/to/forum');
require_once('./global.php');
chdir('/path/to/wordpress');

cashaddy
12-21-2008, 12:31 PM
Perhaps try:
chdir('/path/to/forum');
require_once('./global.php');
chdir('/path/to/wordpress');

don't want wo work :(

the strange => the wordpress vbbridge plugin is working correctly.

that means, the plugin requires the global.php on the same way like me... AND it's working in the plugin ;). but not on the frontend, really really strange.


<?php

$vwd = '/path/forum';

$cwd = getcwd(); /* cwd == "/path" */

chdir($vwd);

if (!file_exists($vwd . '/global.php')) { echo "cannot include $vwd2/global.php. You should check your path!";

exit; }

require_once($vwd . '/global.php');
$useriddd = $vbulletin->userinfo[userid];

chdir($cwd);

echo '"'.$useriddd.'"';

?>

Deceptor
12-21-2008, 12:53 PM
Maybe a wordpress cookie is conflicting, do you have a unique cookie prefix for your vBulletin?

cashaddy
12-21-2008, 01:19 PM
Yes, i have got a unique cookie prefix for my vbulletin...

got the problem: it doesn't want to work in the wordpress theme!!

tested it in the "/" dir in a excluded file and suddendly it did a good job.

damn it. now i have to find a solution for that - i hate such situations :(!

Deceptor
12-21-2008, 01:29 PM
I have an idea, I remember issues with wordpress and variable scope :)

before you call global.php using require, place this code before it:
global $vbulletin;

cashaddy
12-21-2008, 01:40 PM
Put it in the wordpress-theme's functions.php and made a function out of my code, but it didn't want to work...

just added your "global $vbulletin" line, AND IT'S WORKING NOW!!!

Thank you pretty much!!! You gave a great support, dude. :D :D :D

hope this topic helps also some people that want to add some vbulletin content to their wordpress pages!!

Deceptor
12-21-2008, 01:41 PM
No problem man :) Enjoy!