Drupal Role Specific Development Feedback

On rare occasions you may have to work on a production site and need some development feedback.
If you want to control which role sees your output, this snippet can help.

With this logic in place, only appropriate roles will see your working on the site.

<?php
// This is to get whatever is in the if statement to show ONLY for the appropriate user role.
global $user;
$check = array_intersect(array('moderator', 'administrator'), array_values($user->roles));

if (empty($check) ? FALSE : TRUE) {
    // is admin
    echo "Only visable to moderator or administrator.<br />";
}
?>

Leave a Reply

Your email address will not be published. Required fields are marked *