Topic: globals not global when integrating with WordPress
I'm building a site that uses the pun_ functions across the entire site to maintain users while outside of the forum. I'm doing this by including the following code in the header of every page on my site:
define('PUN_ROOT', $_SERVER['DOCUMENT_ROOT'] .'/forum/');
define('PUN_QUIET_VISIT', 1);
require(PUN_ROOT . 'include/common.php');
This has worked great everywhere until I tried to include it in the header of a WordPress template, and received the following error:
Fatal error: Call to a member function query() on a non-object in /forum/include/functions.php on line 122
What I've found is that, for some very strange reason, the variables being made global at the top of the set_default_user() function are not actually becomming global and thus the query() method of the $db object does not exist at that scope. If I reinstantiate the $db object inside of the function, that particular error goes away.
Any idea why this is happening?