Title: $current_user Outside WordPress
Last modified: August 19, 2016

---

# $current_user Outside WordPress

 *  [bradgoss](https://wordpress.org/support/users/bradgoss/)
 * (@bradgoss)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/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.

Viewing 1 replies (of 1 total)

 *  Thread Starter [bradgoss](https://wordpress.org/support/users/bradgoss/)
 * (@bradgoss)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/current_user-outside-wordpress/#post-895908)
 * To anyone who viewed this post and wondered just how this may be done or anyone
   trying this. Goto this [post](http://www.webmasterworld.com/php/3750357.htm#msg3782311)
 * The issue was related to the cookie path restricting access to the /blog portion
   of my domain. There are instructions at that post that will help resolve the 
   issue.

Viewing 1 replies (of 1 total)

The topic ‘$current_user Outside WordPress’ is closed to new replies.

 * 1 reply
 * 1 participant
 * Last reply from: [bradgoss](https://wordpress.org/support/users/bradgoss/)
 * Last activity: [17 years, 7 months ago](https://wordpress.org/support/topic/current_user-outside-wordpress/#post-895908)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
