If user is of a certain role then do something

Change 'administrator' to your required role.

For use in page or node templates.

Snippet:

<?php
 
global $user;

 
// Check to see if $user has the administrator user role.
 
if (in_array('administrator', array_values($user->roles))) {
   
// Do something.
 
}
?>

Comments

neoliminal@drupal.org

How about based on permissions?