user-profile.tpl.php and render($user_profile) not working Pulling my hair out after googling all day to solve this.

I am using a corolla subtheme on drupal 7. I am trying to override the user account edit page in a template file.

For that I am using the default user-profile.tpl.php that comes with core's user module.

But without preprocessing the file won't be recognized by my theme. So I googled here and there and came up with the following:

function mytheme_theme(&amp;$existing, $type, $theme, $path){

  $hooks = array();
    // Make user-profile.tpl.php available
    $hooks['user_profile_form'] = array (
       'render element' =&gt; 'form',
       'path' =&gt; drupal_get_path('theme','mytheme'),
       'template' =&gt; 'templates/user-profile',
       'preprocess functions' =&gt; array('mytheme_preprocess_user_profile_form'),
    );
  return $hooks;
}

function mytheme_preprocess_user_profile_form(&amp;$vars) {
  $args = func_get_args();
  array_shift($args);
  $form_state['build_info']['args'] = $args;
  $vars['form'] = drupal_build_form('user_profile_form', $form_state['build_info']['args']);
}


My php is at a level copy/paste + minor adjustments with a lot frustration.

This preprocessing makes my site read the user-profile.tpl.php, but I can't access the array $user_profile. Instead fields are in the array $form, which misses some fields I need, and all fields miss their default values which should come from the user whose account is shown.

This way I can't rebuild the default password-inputboxes and the 2 new password-inputboxes, and I need a lot of extra php to supply the values for all fields.

I am missing something here, but my knowledge won't go that far that I know what to change, and my google-fu is depleted. I think I need to change some things in the preprocessing-code, so that the array $user_profile is loaded and all the fields have the correct values allready.

How to accomplish this?

How can I make this to work?
In order to have the $user_profile renderable array available within your tpl, you can use the same logic used by Drupal user core module.

Build the content for a user object, loop through each field and assign it to the $user_profile variable.

In your case, it would something like this:

function mytheme_preprocess_user_profile_form(&amp;$vars) 
{
    // load user
    $account = user_load(arg(1));

    if (!$account) {
        // user not found
        return;
    }

    // retrieve all profile fields and attach to $account-&gt;content.
    user_build_content($account);

    // loop through each field attached to the user object
    $vars['user_profile'] = array();
    foreach (element_children($account-&gt;content) as $key) {
        // add it to the $user_profile variable, which will be available in tpl
        $vars['user_profile'][$key] = $account-&gt;content[$key];
    }

    $args = func_get_args();
    array_shift($args);
    $form_state['build_info']['args'] = $args;
    $vars['form'] = drupal_build_form('user_profile_form', $form_state['build_info']['args']);
}