custom user page image field crashes when uploading, removing image I am loading user form with this code

   $account = user_load($user-&gt;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(&amp;$form, &amp;$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

&lt;div class="field1"&gt;&lt;?php print drupal_render($form['field_profile3'])    ?&gt; &lt;/div&gt;


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!
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' =&gt; 'My Title',
    'page callback' =&gt; 'my_page_function',
    'access callback' =&gt; TRUE,
    'file path' =&gt; drupal_get_path('module', 'user'),
    'file' =&gt; '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.