The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Show external page only if logged in
Hello, I already have external pages on a website and am looking to only show the pages if the user is logged into their vBulletin account on the same website. I am unsure what to include in PHP from vbulletin to make this happen.
Basically... if user is logged in then show page. If not, return to the standard vBulletin login form (/forum/login.php?do=login). Any help would be appreciated! |
#2
|
||||
|
||||
You should really check out some of the articles for building your own vBulletin powered pages.
|
#3
|
|||
|
|||
Sorry, this is a separate little app that has already been written. There is many pages and PHP functions. I really just need to know what string I would use to check if the user is logged on or not.
|
#4
|
|||
|
|||
Are you already including vbulletin's global.php in your external pages? If so, you just need to check for $vbulletin->userinfo['userid'] != 0, which will only be true for logged in users.
If you're not including global.php, you need to do that. The "current working directory" needs to be your forum directory (the directory that has global.php) for the include to work. So if that isn't where your external script is located, you would need to chdir() to it before the include and maybe chdir() back to the original directory if other things in your script depend on it. Also, if your external script isn't in the vb forum directory, then for that to work your vbulletin cookie path needs to be set '/' (which I believe is the default), otherwise the vb cookies won't be sent and users won't appear logged in. To be honest I think including global.php does more than you need to do just to check if the user is logged in. I think I remember reading a thread where someone had managed to include the file includes/init.php, which will do less unnecessary work, but I can't remember what needs to be done for that to work. |
#5
|
|||
|
|||
I figured it out. Here is the code I use if anyone else needs it.
Code:
<?php $root_path = $_SERVER['DOCUMENT_ROOT']; chdir($root_path."/forum/"); require($root_path."/forum/global.php"); require_once($root_path."/forum/includes/functions_login.php"); $username = $vbulletin->userinfo['username']; $userid = $vbulletin->userinfo['userid']; if ($userid !=0) { echo "Hello $username"; } else { echo "No account logged in"; } ?> Thanks KH99! |
Благодарность от: | ||
Simon Lloyd |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|