![]() |
pass username and id to a php page in vbulletin
hi,
I tried to pass the variable value by doing this in the global start hook: PHP Code:
PHP Code:
PHP Code:
|
The two php scripts are completely separate, so you can't just set $aaa in one and use it in another. Probably you want to do something like pass it as a parameter, like:
Code:
<iframe id="livechat" frameborder="0" width="100%" height="900" allowtransparency="true" marginwidth="0" marginheight="0" src="http://www.mydomain.com/mypage.php?username={vb:var bbuserinfo.username}&userid={vb:raw bbuserinfo.userid}"></iframe> |
hi kh99,
thanks for the quick response. I know the way you displayed, but that paramer musn't be displayed and or controled by the user because it enable/disabled access to restricted areas. So I must pass the variable directly to the php file as a variable and not via the URL. |
In that case I don't know how you'd do it other than having your script check if the user is logged in, the same way that a vbulletin script would do it. You might want to look at this article: https://vborg.vbsupport.ru/showthread.php?t=228112 . If you follow those instructions to include global.php in your script then you can just user $vbulletin->userinfo.
Another possibility might be to "include" your script, save or capture the output, then include that in a template instead of using an iframe. |
thanks again kh99.
I tried them both but 1. the first one - the php file in the iframe doesn't recognize the https://www.vbulletin.com/docs/html/..._externalfiles global variable $vbulltein global $vbulletin; global $arr; $arr = $vbulletin->userinfo; tried every thing. 2. and the second solution - it is recognized but it displays the php on the whole page and not just in the middle. :( 3. I tried defining a global variable $_SESSION['userid'] = ... in the global_start hook but still nothing. why is this so hard to do?? |
Quote:
|
hi kh99,
I did tried including the global.php file in myfile.php (the file is in the same directory as the global.php file) PHP Code:
|
It seems like that should have worked. Is your script in the same folder as global.php? Are you calling that code in a function, or outside any function?
|
it worked only when I moved the script to the same folder as global.php.
but my script shouldn't be there. My script(s) are in an above folder. meaning in order to include the global.php I need to PHP Code:
I don't understand the reasoning.. |
Quote:
Then what you need to do is chdir() to the forum directory before including global.php, like: Code:
chdir('./forum'); then you can chdir() back to your script directory if you need to. You need to do this because the vb code has relative paths for including other files. |
All times are GMT. The time now is 11:51 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|