Search code examples
drupal-7entityuser-profile

How to load a user profile using entity_metadata_wrapper in Drupal 7


I am trying to get the user profile loaded with entity_metadata_wrapper:

$user_profile = entity_metadata_wrapper('user', $uid);
dpm($user_profile);

but I get nothing back. The user fields load fine with user_load($uid); What am I doing wrong?


Solution

  • entity_metadata_wrapper expects second parameter to be an object, in this case, user object. According to your variable naming, it seems that you are passing user id instead. You can use user_load to fetch user object by ID.