How to check if user is logged in in node.tpl.php and comment.tpl.php
Xano - July 28, 2007 - 07:30
I'm trying to find out how to check whether the current visitor is a logged in user or not. In any other file than node.tpl.php and comment.tpl.php I could easily use $user to check, but this object has got a whole other meaning in those two files. I wasn't able to find anything using Google, so I wondered if anyone here could enlighten me on this. Thanks in advance!

http://drupal.org/node/144735
http://drupal.org/node/144735
User = role GUEST rid =1
http://drupal.org/node/92218
<?php
global $user;
if ( $user->uid ) {
// Logged in user
}
else {
// Not logged in
}
?>
~~
Linux, Drupal5 and Simple Machines Forum R great (got a "non-Russian Bridge yet (for me..))
http://veberu.hostfabrica.ru/index.php
DRUPAL ME BAD!!! & Feel free to contact me (4 faster repsonse) I am happy to look at your site (privately or com
The global part did the
The global part did the trick. Hadn't thought of that. Thanks!
UR welcome .. ~~ Linux,
UR welcome ..
~~
Linux, Drupal5 and Simple Machines Forum R great (got a "non-Russian Bridge yet (for me..))
http://veberu.hostfabrica.ru/index.php
DRUPAL ME BAD!!! & Feel free to contact me (4 faster repsonse) I am happy to look at your site (privately or com
how is it in core themes
Thank you. This is useful, but I have looked through some of the core themes to look how it is implemented in them, and I can't see any code like that above in any of the template/theme files... does anyone know how they do it in the core themes....?
Thanks,
It is very useful information.
ChanHan Hy
Cool...thanks!
Saved me a couple of hours of poking around in code. Thanks a ton!