I have a few instances on my site where I perform actions on User Login.

I create an EntityMetadataWrapper like so:

global $user;
$uw = entity_metadata_wrapper('user', $user);

And then I go to retrieve values like this:

$special_value = $uw->field_special_value->value()

For some reason, this particular line will cause an infinite recursion and crash my site.

Does anyone know what I'm doing wrong here? I am calling one of these from a Rules event and another one from hook_user_login, but it seems like no matter what, I get this recursive error.

This ONLY seems to happen in hook_user_login, all of my other value() calls to Entity Metadata Wrappers seem to work fine.

Note; these are both Entity References -- one references a Taxonomy Term and the other references a custom Entity.

  • Also, if I refresh the page and re-submit the form (via prompt from the browser), everything acts exactly as it should. – tigertrussell Jan 22 '14 at 22:31

are you sure the user is logged in and you have a full $user object available in your rule?

Maybe you have to call $user = user_load($uid, TRUE); explicity for this 1 case?

  • I have step-debugged this problem before, and I am 99% sure that I saw the $user object fully loaded from the global. I will double-check to ensure, and re-post here. – tigertrussell Jan 23 '14 at 0:16
  • I have ensured that the user object is fully loaded. You can see a screenshot of my debugger window here: i.imgur.com/Z5exbeK.png. – tigertrussell Jan 23 '14 at 14:09
  • I noticed that "field_bio" was also an empty array. If I try to load it via $fb = $uw->field_bio->value(); it crashes, as well. – tigertrussell Jan 23 '14 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.