I'm sure this has been covered somewhere, but I haven't been able to find it. I'm trying to use Drupal created users (meaning, I just want to access Drupal's user object: global $user in my php) on pages that won't do any other Drupal activity. This works fine in the "root" directory. So /mysite/index.php (drupal) and /mysite/test.php (non-drupal) this works:

include_once($_SERVER['DOCUMENT_ROOT'] .'/includes/bootstrap.inc'); // same behavior with relative or absolute dirs
drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION); // I've also used DRUPAL_BOOTSTRAP_FULL
global $user;

I have made modifications so all Drupals .inc files are correctly included, but when I try this in a subdirectory - for instance /mysite/subdir/test.php - I get fatal errors on the drupal_bootstrap() line:

Fatal error: Call to undefined function _system_theme_data() in /web/4dnetwork.org/dev2/includes/theme.inc on line 459

Is there another way to use just Drupal's users like this? I won't go into the whole story, but we need to have a number of pages that live outside of Drupal in subdirectories but still use Drupal created users. I don't have a lot of Drupal experience and am concentrating on non-Drupal php pages so I'm betting the solution is a lot simpler than I'm making it!

Thanks for any advice or words of wisdom.

Comments

VinceG’s picture

I haven't had any response yet, but I came up with a really bad work-around. I can grab the user's session cookie left by drupal and use that (actually part of that) to look up user data. The code itself is a bit of a hack, so I won't embarrass myself by posting it. Anyone have an idea for a cleaner way of doing this?