$current_user Outside WordPress
-
Hello,
I’ve been aching over this for several hours and cannot find a solution. I am tying my website to the wordpress database, when a user registers at my site, they are registered for my blog as well.
So far I have been able to register the user at my site or my blog. They are able to login at both sites (they login at my site and they are successfully logged in at the blog site), howwwever, on my site, I cannot access the global $current_user variable.
The beginning of my header file looks like so.
<? /** Make sure that the WordPress bootstrap has ran before continuing. */ require('blog/wp-load.php'); global $current_user; ?>
Later in the file, I print something like the following.
if ( $current_user ) { print "Welcome ".$current_user->user_login; } else { ... sign in etc etc }
But that will not show anything. And $current_user->ID returns 0.
Could anyone suggest how I may access this variable? I’ve tried wp_getcurrentuser and trying to mess with the cookies, but I still can’t get it working!
Thank you.
- The topic ‘$current_user Outside WordPress’ is closed to new replies.