How to update custom user field on form submit I want to create a basic page that has only one of my custom user account fields listed, and available to edit.

For example, I have a custom user account field: field_companyname

Rather then directing the user to go to www.example.com/?q=user/1/edit,
I want the user to go to a different page (i.e www.example.com/node/5).
On this page, there should only be a single text input field, and a submit button to save the new data to the user account.

I'm pretty sure I need to implement user_save(), but I just don't know where to go from here.

// load user object
$existingUser = user_load('USERID');

// update some user property
$existingUser-&gt;some_property = 'foo';

// save existing user
user_save((object) array('uid' =&gt; $existingUser-&gt;uid), (array) $existingUser);


Any help or pointers would be much appreciated. Thanks for looking!

EDIT: I was able to load the entire user account edit form onto a node using the following code:

&lt;?php
  module_load_include('pages.inc', 'user', 'user');
  global $user;
  $account = user_load($user-&gt;uid);
  $output = drupal_render(drupal_get_form('user_profile_form', $account));
  return $output;
?&gt;


However, I still cannot figure out how to display ONLY my single custom field. Any help is greatly appreciated.

EDIT #2: I used CSS to hide the other fields that I did not want to display. Seems like there should be a better way to do this. But I guess this will work for now, unless anyone else can chime in :-)

Thanks again for looking.
Use field_attach_form in your page with the field name and user object. You can use field_attach_form_validate and field_attach_submit
to validate and submit the values.