Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By NicolasH on
I would like to expose certain areas of pages only to admins, just like Drupal does out of the box, but incorporate that in my template.
Eg
<?php if ($user == 'admin') { ?>
Important Stuff
<?php } ?>
What are the variables I have to look for?
Thanks
Comments
snippet
If you want to display something to certain roles, you could use
If you mean user1:
If there's a specific
If there's a specific permission you're wanting to check against, you can also use the following:
hook_menu() uses that to restrict access based on role permissions.
Many thanks, guys. Exactly
Many thanks, guys. Exactly what I was looking for...
Could someone point me to a resource that lists the variables that I can access on a page (like the $user array above)?
Cheers
Hmm.. I'm not sure if there
Hmm.. I'm not sure if there is one. hehe Maybe someone else knows of one, but I've just learned by developing for Drupal. Learning as you go...