Unable to retrieve user id of edited user from $entity in hook_field_validate I have this little problem with a custom field that is bundled with user. In its validation function I need to have access to the user id of the user whose field is being edited.

What that means is, when I edit a user, I need to get his uid in the validation function.

The problem is that hook_field_validate provides just $entity variable that doesn't include uid.

I know I could load the user object using his email / name (and then retrieve the uid from it) but it wouldn't properly work when email/name was being changed (I could get only the changed values from $entity and therefore wouldn't be able to load the object properly).

Any ideas?
You can always get this information from the path, eg:

// you are sitting on user/#/edit

$uid=arg(1);                      // quick, or...
$account=menu_get_object('user'); // the full user object, eg the uid is in $account-&gt;uid