Ordering fields in template.php file I am trying to theme the user s profile edit form. I Have added a class to the form and the look changed. However i am still struggling to find out how to order the fields in the way i want directly in the template.php file. 
Here is my code : 

if ($form_id == 'user_profile_form') {
//dsm($form);
//kpr($form);
$form['#prefix'] = '&lt;div class="nano-ui"&gt; 

&lt;h1 class="formtitle"&gt; Modifer vos informations&lt;/h1&gt;
';
    $form['#suffix'] = '&lt;div style="margin-bottom:100px"&gt;&lt;/div&gt;&lt;/div&gt;';

    $form['field_civilite']['#prefix'] = '&lt;div style="margin-bottom:10px"&gt;


&lt;div class="notification info  margin" style="margin-top:25px" &gt;
        &lt;h1&gt;Informations personnelles du membre&lt;/h1&gt;
      &lt;/div&gt;&lt;/div&gt;
';  


$form['field_nom'][und][0][value]['#attributes']['class'] = array("nui-input");
$form['field_prenom'][und][0][value]['#attributes']['class'] = array("nui-input");
$form['field_personne_morale'][und][0][value]['#attributes']['class'] = array("nui-input");


$form['locale']['#prefix'] = '&lt;div style="margin-bottom:10px"&gt;
&lt;div class="notification info  margin" style="margin-top:25px" &gt;
        &lt;h1&gt;Preferences compte &lt;/h1&gt;
      &lt;/div&gt;&lt;/div&gt;
';   



$form['account']['current_pass']['#attributes']['class'] = array("nui-input");
$form['account']['mail']['#attributes']['class'] = array("nui-input");
//$form['field_civilite']['#suffix'] = '&lt;span class="radio"&gt;&lt;/span&gt;';
$form['field_pays_users'][und]['#attributes']['class'] = array("select");
$form['field_profession'][und]['#attributes']['class'] = array("select");
$form['field_conditions_enregistrement'][und][0][value]['#attributes']['class'] = array("dislaynone");
$form['field_conditions_enregistrement']['#prefix'] ='&lt;div class="dislaynone"&gt;';
$form['field_conditions_enregistrement']['#suffix'] = '&lt;/div&gt;';


$form['actions']['submit']['#attributes']['class'][] = 'nui-button green'; 
$form['actions']['cancel']['#attributes']['class'][] = 'nui-button red'; 

}


Is there a way to override UI that manages the fields display for drupal users ?
Firstly, why template.php for reordering the fields of an entity edit form? You should put this logic in a module and not a theme, look up hook_fomr_alter and hook_form_FORM_ID_alter.

Secondly, if the profile is the default user profile in D7 or you have created one using profile2, you can go to the manage fields section of the entity and reorder the fields just by dragging them. That should change the order on both view page and edit page of the entity, no?

Can you try it out and see if it works! You might not need to write code at all!