How to load a field from a user that is being viewed I am looking to load a field from a user's profile that is being viewed.For example, I am looking at another users profile and it will load their associated field.

I am programmatically adding a picture to the tpl (probably should be template.php) and then I am adding it to the background-image of a div. My code loads the user but then switches the user to user being viewed. It is obviously not good to be able to switch users.

Here is my code:

&lt;?php
   $user = user_load(arg(1));
   $picture = field_get_items('user', $user, 'field_picture');
   $file = $picture['filename'];
   $url = $base_url . '/files/' . $file;
&lt;?


I cannot find a secure way to do this. Anyone have an idea?

Thank you for your time.
Try creating a user-profile.tpl.php file in your theme and messing around with that.

Default contents are:

&lt;div class="profile"&gt;
  &lt;?php print $user_profile; ?&gt;
&lt;/div&gt;


And I suggest using a variable name other than $user as $user is a global variable referring to the logged in user.