6.x user.pages.inc user_profile_form($form_state, $account, $category = 'account')
7.x user.pages.inc user_profile_form($form, &$form_state, $account, $category = 'account')

Form builder; edit a user account or one of their profile categories.

See also

user_account_form()

user_account_form_validate()

user_profile_form_validate()

user_profile_form_submit()

user_cancel_confirm_form_submit()

Related topics

3 string references to 'user_profile_form'
locale_form_alter in modules/locale/locale.module
Implements hook_form_alter().
profile_form_alter in modules/profile/profile.module
Implements hook_form_alter().
user_menu in modules/user/user.module
Implements hook_menu().

File

modules/user/user.pages.inc, line 283
User page callback file for the user module.

Code

function user_profile_form($form, &$form_state, $account, $category = 'account') {
  global $user;

  // During initial form build, add the entity to the form state for use during
  // form building and processing. During a rebuild, use what is in the form
  // state.
  if (!isset($form_state['user'])) {
    $form_state['user'] = $account;
  }
  else {
    $account = $form_state['user'];
  }

  // @todo Legacy support. Modules are encouraged to access the entity using
  //   $form_state. Remove in Drupal 8.
  $form['#user'] = $account;
  $form['#user_category'] = $category;

  if ($category == 'account') {
    user_account_form($form, $form_state);
    // Attach field widgets.
    $langcode = entity_language('user', $account);
    field_attach_form('user', $account, $form, $form_state, $langcode);
  }

  $form['actions'] = array('#type' => 'actions');
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  if ($category == 'account') {
    $form['actions']['cancel'] = array(
      '#type' => 'submit',
      '#value' => t('Cancel account'),
      '#submit' => array('user_edit_cancel_submit'),
      '#access' => $account->uid > 1 && (($account->uid == $user->uid && user_access('cancel account')) || user_access('administer users')),
    );
  }

  $form['#validate'][] = 'user_profile_form_validate';
  // Add the final user profile form submit handler.
  $form['#submit'][] = 'user_profile_form_submit';

  return $form;
}

Comments

kiamlaluno’s picture

In Drupal 8, this function has been replaced with entity_get_form().