diff --git a/field_permissions.api.php b/field_permissions.api.php new file mode 100644 index 0000000..87cb49b --- /dev/null +++ b/field_permissions.api.php @@ -0,0 +1,22 @@ +uid. + * @param object $entity + * The entity this field belongs to. + */ +function hook_field_permissions_userid_ENTITY_TYPE_alter(&$uid, $entity) { + // This example always assigns user 15 as the owner of an entity. + $uid = 15; +} diff --git a/field_permissions.module b/field_permissions.module index bc4d1f5..5e4ab56 100644 --- a/field_permissions.module +++ b/field_permissions.module @@ -258,5 +258,10 @@ function _field_permissions_entity_is_owned_by_account($entity, $account) { // set (for example, if the entity type does not store a uid or does not have // a concept of "ownership"), we need to assume that the provided user // account does not own it. - return isset($entity->uid) && $entity->uid == $account->uid; + $uid = isset($entity->uid) ? $entity->uid : FALSE; + if(method_exists($entity, 'entityType')) { + drupal_alter('field_permissions_userid_' . $entity->entityType(), $uid, $entity); + } + + return $uid == $account->uid; }