Display for logged in users

Last modified: July 24, 2007 - 02:47

The following code will return TRUE for logged in users.

<?php
global $user;
return (bool)
$user->uid;
?>

To use this to only show to users that are NOT logged in you need to add an exclamation point (!) like so:

<?php
global $user;
return (bool) !
$user->uid;
?>

This check is no longer necessary in Drupal 5.x + since the block settings let you select who may view the block by role with check boxes.

 
 

Drupal is a registered trademark of Dries Buytaert.