Hook_node_grants: how do I access a user account field? Here is my implementation of hook_node_grants:

/**
 * Implements hook_node_grants().
 */
function gcac_node_grants($account, $op) {

    // Declare $user as having global scope.
    global $user;

    // Permit a user to view the node if the node and user are assigned the same 
    // group.
    ** if ($user-&gt;field_group[LANGUAGE_NONE][0]['value'] == $node-&gt;group &amp;&amp; $op == 'view') {
        $grants['gcac_view'] = GCAC_ALLOW;
    }

    // Permit the user to edit the node if the node and user are assigned the same 
    // group, and the user is the author.
    ** if ($user-&gt;field_group[LANGUAGE_NONE][0]['value'] == $node-&gt;group &amp;&amp; $user-&gt;uid == $node-&gt;uid &amp;&amp; ($op == 'update' || $op == 'delete')) {
        $grants['gcac_edit'] = GCAC_ALLOW;
    }
    return $grants;
}


I have added a field to my user accounts called 'Group' and populated it with a value for several accounts. Yet, here is the error that is being thrown:


  Notice: Undefined property: stdClass::$field_group in
  gcac_node_grants() (line 21 of
  /homepages/99/d99999999/htdocs/node-access2/sites/all/modules/gcac/gcac.module).


As you can see I'm trying to access the 'Group' of the current user so that I can compare it  to the 'Group' assigned no a node. I just want to access the value. Originally, I tried accessing $account->field_group[LANGUAGE_NONE][0]['value'], but I got the same error.

I can go grab it from the database, if I have to because I know I can access $user->uid, but surely the user module is providing my the field for me use? Thanks.
As per your error statement, field_group does not exist in $user object. The global $user object does not load the fields which are attached to user profile. if you want to load the complete user profile with attached fields, you need to use function "user_load" in your code.

global $user;

$account = user_load($user-&gt;uid);
if ($account-&gt;field_group[LANGUAGE_NONE][0]['value'] == $node-&gt;group &amp;&amp; $op == 'view') {
  //Do the needful
}