Wordpress: unable to get the user logged in
The header.php in my project includes at the very beginning a php file
with content like this:
global $profile;
global $user;
if(is_user_logged_in()){
global $current_user;
get_currentuserinfo();
$user = array();
$user['username'] = $current_user->user_login;
$user['email'] = $current_user->user_email;
..
..
}
On my page template file I am trying to get info from this user object,
through the following code
$.ajax({ url: path + '/gmail/user.php',
type: 'post',
success: function(status) {alert(status);} }
});
which is calling
<?php
print_r($user);
?>
and I get an empty alert. I get this whether I log in or not. Why could
this happen? Is there another solution to picking up the logged in user?
maybe with sql?
No comments:
Post a Comment