Submitted by Kiran on Tue, 03/17/2009 - 08:50
It is always possible to check if the user is logged in as admin using the drupal built in user_access() function, super administrator account doesn't have a role by default so you can check it using :
<?php
if(user_access('administer'))
{....your code goes here....}
?>
However, in case if you want to check whether the logged-in user has a certain role. For example, something like this if you have a role called 'moderator'
<?php
global $user;
if(is_array($user->roles) && in_array('moderator', $user->roles))
{... your code goes here ...}
?>
»
- Kiran's blog
- 3814 reads













in_array('moderator', array_values($user->roles))
Post new comment