The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Is it possible to include global.php in functions and if statements
Hello,
I'm having problems attempting to include global.php inside functions and if statements. I also have problems including global.php outiside if statements and then using the data manager "tools" inside the if statement. The goal is to add a registered user to additional group(s) using the data manager tools if certain conditions are met. When I attempt to include global.php either in a function or if statement and then make a call to fwrite, nothing gets written to my file, and the user is not added to the additional groups. It's like php and/or vbulletin goes in la-la land. Including global.php and $vbulletin works outside any if statements and functions. However, that is assuming one condition is always met. I need to be able to check for multiple conditions and that's why I'd like to be able to at least use if statements and then reference $vbulletin to manipulate the user's groups inside the different if statements (leveraging the data manager "tools"). So I need to be able to do something like (pardon my pseudo-code): include_once(dirname(__FILE__) . "/global.php"); global $vbulletin; $email = "momma@mommashouse.com"; if ($userlikestheHoustonTexans == "yes") { // update membergroupids to add more access $useridq = $vbulletin->db->query_first_slave("SELECT userid FROM " . TABLE_PREFIX . "user WHERE email='{$email}'"); $syd_userinfo = fetch_userinfo($useridq['userid'], 0, 0); $finalmembergroupids = $syd_userinfo['membergroupids'] . ",9"; $file = fopen(dirname(__FILE__) . "/test.txt","a"); fwrite($file, "made it past including global php \r\n"); fclose($file); } else { // remove membergroupids to deny access since they don't like the TEXANS - boo } //do presave //check for errors with presave // if no errors with presave, then really save the users updated information But declaring global.php outside any if statements and then referencing $vbulletin in the different if statements is not working. Thanks for any help you can provide! |
#2
|
|||
|
|||
You should be able to include global.php inside an if statement, but the current directory needs to be the directory where global.php is (your forum directory). So if the script that includes global.php is not there, you need to do something like:
Code:
chdir('path/to/forum'); include_once("global.php"); // chdir() back if necessary Including it inside a function is possible, but to do it there are certain variables that need to be declared as global *before* the include, and I don't know offhand what they all are - obviously $vbulletin is one, I think $bootstrap might be another. Maybe you could write a test script and call get_defined_vars() before and after including global.php, then diff the arrays and see what vars were created (although some of them may not be needed after global.php is done). |
#3
|
|||
|
|||
Thanks for the response. I'll give it a shot later this evening.
Thank you for taking the time to respond. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|