Last active
December 28, 2015 18:59
-
-
Save tanmayk/7546871 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_field_access(). | |
* Check if user has access for the field. | |
*/ | |
function MYMODULE_field_access($op, $field, $entity_type, $entity, $account) { | |
if ($entity_type == 'user') { | |
switch ($op) { | |
case 'view': | |
global $user; | |
// Implement you access logic here for each field. | |
// $entity is user which is being viewed. | |
// You will get his privacy setting for single field in $entity->data['privacy_settings'][$field['field_name']]. | |
// If you want, you can use the constants defined above. | |
// If current user has access to field then return TRUE, else FALSE. | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment