I'd like to know how to override/change the default fields in user profile such as: button Save, name, timezone etc.
I'd like to alter, delete('cause i don't need them) some of them.
To alter the user profile i use the hook: hook_form_alter
using which i managed to add my own fieldds to user profile. But now i want to alter the default fields. How can i do it?
It is possible with the hook_form_alter
, though it is better to use hook_form_FORM_ID_alter
!
To be able to alter the form you need to know the structure of the arrays, the easiest way to get to know this is by installing the Devel module. Then you can view the structure by placing dpm($form);
inside your alter function.
You can use this function on your custom module or in your theme (in template.php
file).
Usually user profile form_id is user_profile_form
. A simple example would be:
function mymodule_form_user_profile_form_alter(&$form,$form_state,$form_id){
$form['timezone']['#access'] = FALSE; //remove the "timezone" field from the form (default value is still saved)
$form['field_somefield']['#weight'] = -50; //move the field up
$form['actions']['submit']['#value'] = t('Add this content now'); //change the submit button text
}
For a good tutorial see the Lullabot tutorial here (is for drupal 6 but works the same way for d7!).