Not quite sure why this is happening, hopefully someone can help. I have a wordpress installation, lets say for arguments sake it's installed to http://www.example.com/wordpress. I have a file called test.php with the following code:
<?php
include '/php_path_to_blog/wp-blog-header.php';
echo get_current_user_id();
?>
Now the odd part is if i have a user logged in and place this file within my wordpress directory and call it by going to http://www.example.com/wordpress/test.php it outputs the correct user id of the current logged in user. However if I move the file to the root directory of the site and call it by going to http://www.example.com/test.php, it outputs 0 as if there were no user logged in.
It seems that some functions work properly outside of the installation directory and some don't. I would like them to work outside the wordpress isntallation directory.
Any help would be greatly appreciated.
<pre><?php print_r(get_defined_vars)); ?></pre>It will show you every variable currently available in a nicely formatted display. You might try putting this under your include statement to see what (if anything) is being called and how to access it. – SickHippie Mar 9 '12 at 20:34(). That function has saved me hours of trouble, if not days. – SickHippie Mar 9 '12 at 21:08