0

I have a specific content type with it's own node template. When I go directly to the node all user information from the $user variable is accessible. However when I load this node with node_view into another page any of the code in the template that is dependent upon the user info breaks because the template doesn't register the user as logged in. Is there something special I need to do to make it properly populate the $user variable?

Edit

This is at the top of my node--product.tpl.php (the node template I'm loading).

 global $user;
 print_r($user);

This returns:

stdClass Object ( [uid] => 0 [hostname] => ###.###.###.### [roles] => Array ( [1] => anonymous user ) [cache] => 0 ) 
  • Have you checked $GLOBALS['user']? – ya.teck Apr 30 '14 at 15:24
  • yes. a print_r of it returns: stdClass Object ( [uid] => 0 [hostname] => ###.###.###.### [roles] => Array ( [1] => anonymous user ) [cache] => 0 ) – LoneWolfPR Apr 30 '14 at 15:27
  • global $user;? – Felix Eve Apr 30 '14 at 15:28
  • returns same thing. – LoneWolfPR Apr 30 '14 at 15:29
  • 1
    You are accessing page as anonymous user that's the reason it displays above output.. global $user; will get the logged in user details.. – Anil Sagar Apr 30 '14 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.