$user Conditionals
This is one example of performing an action based on whether or not the current user belongs to a certain role or roles. Note that the admin user (UID #1) matches as well.
1 2 3 4 5 6 7 8 |
global $user; $roles = array_values($user->roles); if (in_array('admin', $roles)) || in_array('developer', $roles)) || $user->uid == 1) { print $content; } else{ header("location:/not-allowed"); } |
Note: You may want to try using drupal_goto() (or drupal_access_denied() in this case) instead of a header redirect.