Skip to content

Instantly share code, notes, and snippets.

@martsie
Created January 25, 2017 10:18
Show Gist options
  • Save martsie/c08b0c69cf2b48c47ca5a323f2a6369c to your computer and use it in GitHub Desktop.
Save martsie/c08b0c69cf2b48c47ca5a323f2a6369c to your computer and use it in GitHub Desktop.
A simple implementation of a core permission check in Drupal 7
<?php
/**
* Implements hook_init().
*
* Runs every time a page is requested on the site.
*/
function my_custom_module_init() {
if (user_access('access content')) {
drupal_set_message(t('User has Drupal core access content permission'));
}
else {
drupal_set_message(t('User does not have Drupal core access content permission'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment