Check if user is logged – Drupal

This is really very basic, but important when you want to show some content that should only be viewable by authenticated users:

<?php
global $user;

if ( $user->uid ) {
  // Logged in user - Show content you want for authenticated user
}
else {
  // Not logged in
}
?>
Tags: ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*