Text Size
Sunday, May 20, 2012
Get a look down
General >> Code snippets >> How to check if the actual user is logged in Drupal
Tuesday, 23 August 2011 08:54

How to check if the actual user is logged in Drupal

Written by Nabil Sadki
Rate this item
(0 votes)

You can check by this little snippet if the actual user visiting your website is logged in or not. This snippet can be used anywhere (modules, themes, blocks..)

1
2
3
4
5
6
7
8
9
<?php
  global $user;
  if ($user->uid) {
    // User is logged in. Do something.
  }
  else {
    // User in anonymous. Do something.
  }
?>
Last modified on Tuesday, 23 August 2011 08:58
Nabil Sadki

Nabil Sadki

Hello, I am Nabyl, a Freelance web developer and a joomla addict. I have made many sites using the latter, but also patches for the core of this CMS. I like HipHop culture and world of warcraft. You can find find me on Twitter when i'm free...

Website: www.coins.ma E-mail: This e-mail address is being protected from spambots. You need JavaScript enabled to view it

Add comment



Usefull tricks