Step 1.
Tell template.php to use your own template located inside your theme folder YOURTHEME/templates/user-profile-edit.tpl.php
function YOURTHEME_theme() {
return array(
// The form ID.
'user_profile_form' => array(
// Forms always take the form argument.
'arguments' => array('form' => NULL),
'render element' => 'form',
'template' => 'templates/user-profile-edit',
),
);
}
Step 2.
Create sites/all/themes/YOURTHEME/templates/user-profile-edit.tpl.php
print render($form['form_id']);
print render($form['form_build_id']);
print render($form['form_token']);
print render ($form[‘field_user_firstname’]);
print render ($form[‘field_user_lastname’]);
print render ($form[‘field_user_dob’]);
<input type=”submit” name=”op” id=”edit-submit” value=”Save”Ā />
Step 3.
Customize the CSS to design the form the way you want
I plan on using this to make a multi-page edit form. I will be breaking down the different user fields based on category rather than just dumping everything into one long and boring form.
Thanks for the post! It really helped me out!
how to get the user picture field…
i figured it myself…just do: print drupal_render_children($form);
or print render($form[‘picture’]);
not working for me i follow all step descibe below but its not working where i go to
user/me/edit URL
thank you for your help
Is anyone can help me ?
this code snippet is not working in drupal 7 plaese help
What do you mean by its not working? What error are you receiving?
Hmmm, I also can’t get it to work. I have checked user.module to see what it does when someone accesses path user/%user/edit and it basically does a drupal_get_form(‘user_profile_form’, $uid).
And I can’t find any $form[‘#theme’] in user_profile_form() which would then make use of the template file. So I’m a little bit lost here.
Is there perhaps something else missing?
Thanks
I’ll look into this and get back to you. I posted this a really long time ago so it is possible with the latest upgrades to Drupal 7, they have changed how the backend is delivered. What specifically are you trying to do?
I am trying to modify some of the wording on the user edit form but its not usering the user_profile_form that I specify with templates/user-profile-edit
are you sure it’s called user_profile_form in drupal 7 ? its not picking it up
Hi.. This is an excellent page.. But still I want to know how to print the email field as well as as password fields separately. tried print render ($form[‘mail’]); but of no use š¦
I got it
print render($form[‘account’][‘mail’]);
š
I was able to customize the profile edit page but the submitted form doesn’t appear to register. is there a function I should change in the templates file? I’m using drupal 7.
Pingback: [Drupal]All about theming | jolam
Please try refreshing the ‘theme registry’ cache.
thanx. it helped me a lot.
Hello, when i click save, nothing happens, fields have old values. What is the cause? Pls help.
It’s working with Drupal 7 as well, but not for user 1.
This is very nice. I wanted to know if we can hide edit user profile anyhow.
I wanted to hide email, password, timezone each filed in Drupal-7 for some of specified user role.
I tried these two functions in my new custom module called first, but no luck:
—————————
function first_alter(&$form, &$form_state, $form_id) {
// changed form id
if ($form_id === ‘user_form’ AND $account->uid == 178) {
// Use var_dump to dump the $form array to see the fields.
var_dump ($form);
hide($form[‘account’][‘pass’]);
hide($form[‘account’][‘current_pass_required_values’]);
hide($form[‘account’][‘current_pass’]);
}
}
————————–
function first_form_user_profile_form_alter(&$form, &$form_state) {
global $user;
if(in_array(‘enrolled student’,$user->roles)) {
$form[‘account’][‘pass’][‘#access’] = FALSE;
// Similarly other fields, but fields can not be required fields on profile.
}
}
hide($user_profile[‘summary’][‘member_for’]);