Show different content to anonymous and authenticated users

tags: Drupal   php snippets  
drupal tags: users   contents  

<?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.";
}
?>


Similar:

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <p> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h2> <h3> <h4> <img> <hr>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

Archives

February 2012
SunMonTueWedThuFriSat
1234
567891011
12131415161718
19202122232425
26272829
PureDivs Drupal Themes Conversions
PureDivs Conversione Temi Drupal