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.
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() instead of a header redirect.


Add new comment