Hi,

I'm using hook_field_access() to control access to profile2 entities. While some fields are publicly visisble, some require conditions to be met before they can be viewed. The code works as it should.

However, on profiles where the private fields are seen, the page gets the title 'Access denied'. The content of the page is correct however!

On profiles that display only public fields, the page title is correct.

Here's the function, although I don't know that the problem lies here...

<?php
function clockmein_permissions_field_access($op, $field, $entity_type, $entity, $account) {
  if (isset(
$entity) === TRUE AND empty($entity) !== TRUE AND $op == 'view' AND $entity_type == 'profile2') {
   
$linked_vols = &drupal_static('linked_vols');
    if (isset(
$linked_vols) !== TRUE) {
     
$linked_vols = _clockmein_linked_user_to_volunteer($account->uid, $entity->uid, TRUE);
    }
    if (
in_array($entity->uid, $linked_vols) === TRUE OR in_array($field['field_name'], public_profile_fields()) === TRUE) {
      return
TRUE;
    } else {
      return
FALSE;
    }
  }
}
?>

_clockmein_linked_user_to_volunteer() is the condition that needs to be met for the private fields to be viewed. public_profile_fields() just returns a list of fields names that can be viewed by the public.

Like I said, this actually works, it's just the page title that's got me puzzled.

Thanks in advance for any insights.

Matthew

Comments

It's the posting that triggers the solution!
I needed to rebuild the permissions. Once done, all was well.
Matthew