Display different page content to anonymous and authenticated users

Last modified: October 6, 2006 - 00:27

PLEASE NOTE! The following snippets are user submitted. Use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

<?php
/**
* The following simple snippet
* displays different information to anonymous/logged in users within a page.
*
* This works with drupal 4.5 and drupal 4.6
*/
global $user;
if (
$user->uid) {
    return
"This message is only visible for logged-in users.";
}
if (!
$user->uid) {
    return
"This message is only visible for not-logged-in users.";
}
?>

 
 

Drupal is a registered trademark of Dries Buytaert.