I need to split the account edit form that shows up on one page to multiple pages. That means I want to separate change password fields, two custom fields i created - field_first_name and field_last_name and so on. For moving the password fields to new block I used the solution provided in this link How can I display a change password form on its own? and it works great.

I am trying to use the same code except make some minor changes for modifying the custom fields (first name and last name). The only difference is, I need to pre-populate these fields with the values from the current logged in users information.

// Get the currently logged in user object.
$form['#account'] = $GLOBALS['user'];

// Textfield for first name.
$form['field_first_name'] = array(
  '#type' => 'textfield',
  '#title' => t('First Name'),
  '#size' => 60,
  '#default_value' => // What should I enter here?
  '#required' => TRUE,

When I enter a new value for these fields, it doesn't get updated in the account. I am using the following code.

 * Submit handler for change_name_form().
function change_name_form_submit(&$form, &$form_state) {
  // Set up the edit array to names to user_save().
  $edit = array(
    'field_first_name' => $form_state['values']['field_first_name'],
    'field_last_name' => $form_state['values']['field_last_name'],

  // Save the account with the new name.
  user_save($form['#account'], $edit);

  // Inform the user.
  drupal_set_message(t('Your information has been changed.'));

What changes do I need to make to the code to get the desired output?

1 Answer 1


I haven't done this in code, but I split the user profile into multiple pages on my site with the Field Group module (as the module's page says, it is only client-side).

There is a screencast about how the multipage features work.

Another option is the Profile 2 module, which will create actual separate paths for different settings.

  • I want to allow non-linear access to the pages containing the form fields - which means the user should not need to click 5 times to reach the last fields on the form, which would be on the 5th page based on the example in the screencast above, so thats not what I have in mind. I want to place the blocks on separate pages with links in the user submenu. So if users want to only change passwords, users can click on any menu link and they will be provided with just change password fields. The link I posted in my question allows me to do that. Now I am looking to place other fields in blocks. Jun 19, 2012 at 20:14
  • Ok, if you were looking for a module, perhaps Profile 2 is a better fit. See my updated answer. Jun 20, 2012 at 1:34
  • Yes. Thats the path I am planning to take. I will post my approach if it succeeds. Thanks for providing the info.. Jun 21, 2012 at 19:14
  • I appreciate the answer, however I don't see any setting that allows me to separate each profile 2 field to its own edit form. Could you point out how to accomplish this?
    – Anon Ymous
    Oct 4, 2015 at 7:20

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