I am loading user form with this code

   $account = user_load($user->uid);
  module_load_include('inc', 'user', 'user.pages');
  $userform = drupal_get_form('user_profile_form', $account);
  return drupal_render($userform);

I have a image field in the form and i'm altering form to append another template file

function customuserprofile_form_alter(&$form, &$form_state, $form_id, $account = 'account') {
  switch ($form_id) {
    case 'user_profile_form':

 $form['#theme'] = 'custom_profile_form'; 

and i am printing this field in custom-profile-form.tpl.php

<div class="field1"><?php print drupal_render($form['field_profile3'])    ?> </div>

it is ok that code is showing me image field but when i click upload or remove button in image field i get this error

Notice: Undefined index: user_profile_form in drupal_retrieve_form() (line 760 of Z:\home\drupaler.uz\www\includes\form.inc).
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'user_profile_form' not found or invalid function name in drupal_retrieve_form() (line 795 of Z:\home\drupaler.uz\www\includes\form.inc).
Notice: Undefined index: #user_category in block_form_user_profile_form_alter() (line 563 of Z:\home\drupaler.uz\www\modules\block\block.module).
Notice: Undefined index: #user in ckeditor_user_customize() (line 41 of Z:\home\drupaler.uz\www\sites\all\modules\ckeditor\includes\ckeditor.user.inc).
Notice: Trying to get property of non-object in ckeditor_user_customize() (line 41 of Z:\home\drupaler.uz\www\sites\all\modules\ckeditor\includes\ckeditor.user.inc).
Notice: Undefined index: #user_category in system_form_user_profile_form_alter() (line 1954 of Z:\home\drupaler.uz\www\modules\system\system.module).
Notice: Undefined index: field_profile in file_ajax_upload() (line 271 of Z:\home\drupaler.uz\www\modules\file\file.module).
Notice: Undefined index: #suffix in file_ajax_upload() (line 280 of Z:\home\drupaler.uz\www\modules\file\file.module).

problem is that image field works uncorrectly with in my page. but it is ok in /user/1/edit page Maybe ajax in uploading, removing image needs some corrections or any hacks? Please help me I'm in trouble!

2 Answers 2


In the menu entry for your custom page, if you have not already done so, you need to add the file path and file to reference the user module files, like so...

$items['my/custom/page'] = array(
    'title' => 'My Title',
    'page callback' => 'my_page_function',
    'access callback' => TRUE,
    'file path' => drupal_get_path('module', 'user'),
    'file' => 'user.pages.inc', 

I find it's necessary to include the reference in the function, as you have already done, and also include it in the menu entry. Don't forget to clear the Drupal cache after updating the menu entry.


To create a custom page for user account form you should go this way:

$account = user_load($user->uid);
$form_state['build_info']['args'][] = $account;
form_load_include($form_state, 'inc', 'user', 'user.pages');
$userform = drupal_build_form('user_profile_form', $form_state);
return drupal_render($userform);

source: https://www.drupal.org/node/1336212#comment-6056524

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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