Drupal Check if User Has Role

/ Published in: PHP
Save to your folder(s)

Copy this code and paste it in your HTML
  1. <?php
  2. global $user;
  4. // Check to see if $user has the administrator role.
  5. if (in_array('administrator', array_values($user->roles))) {
  6. // Do something.
  7. }
  8. ?>

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.