well it took a while but here’s a solution (and a more specific description of the problem). i have wordpress installed in a folder in my root directory named wordpress. also in the root directory is a file called test.php with this content:
<?php
require_once('wordpress/wp-config.php');
get_currentuserinfo();
print "$user_login<br/>$user_ID<br/>$user_level<br/>";
?>
the reason this doesn’t work is because the function get_currentuserinfo()
always returns false before setting the user info variables. it does a check to see if the correct cookies are set, and when it can’t find them, you lose. the reason no cookies are found is because the cookies are set with the path of your wordpress install, and so are not sent unless accessing a page in the wordpress directory. I KNOW NOTHING ABOUT COOKIES except what i’ve figured out experimenting over the last few hours – this may be incredibly insecure. that said, a workaround is to set extra cookies. there are two function dealig with cookies (wp_setcookie() and wp_clearcookie()), both in [wordpress root directory]/wp-includes/pluggable-functions.php.
to wp_setcookie() i added the two lines:
setcookie(USER_COOKIE, $username, $expire, '/',
COOKIE_DOMAIN);
setcookie(PASS_COOKIE, $password, $expire, '/',
COOKIE_DOMAIN);
after the lines:
setcookie(USER_COOKIE, $username, $expire, $cookiepath,
COOKIE_DOMAIN);
setcookie(PASS_COOKIE, $password, $expire, $cookiepath,
COOKIE_DOMAIN);
and the lines:
setcookie(USER_COOKIE, $username, $expire, '/',
COOKIE_DOMAIN);
setcookie(PASS_COOKIE, $password, $expire, '/',
COOKIE_DOMAIN);
after
setcookie(USER_COOKIE, $username, $expire,
$sitecookiepath, COOKIE_DOMAIN);
setcookie(PASS_COOKIE, $password, $expire,
$sitecookiepath, COOKIE_DOMAIN);
to wp_clearcookie() i added the following lines at the end:
setcookie(USER_COOKIE, ' ', time() - 31536000, '/',
COOKIE_DOMAIN);
setcookie(PASS_COOKIE, ' ', time() - 31536000, '/',
COOKIE_DOMAIN);
seems to work – if ive done something horrible id appreciate anyone pointing out…