Drupal Checking if logged in user is admin


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



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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.