The password inputs are in fact a separate form element (password_confirm
-- Form API reference) and although it is themable (see theme_password_confirm), all you can influence is the description, prefix/postfix and element title.
The real work happens in expand_password_confirm, which in turn is a process function specified in system_elements. The latter is an implementation of hook_elements and it lets Drupal know how to handle various form elements.
Luckily, one can use hook_elements()
to specify custom form elements and that is the one you can use to override the system processing for the password_confirm element.
A sample implementation follows:
<?php
/**
* Implementation of hook_elements()
* @see http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_elements/6
*/
function mymodule_elements() {
$type['password_confirm']['#process'][] = 'mymodule_process_password_confirm';
return $type;
}
/**
* Do a bit of processing for the password_confirm element.
* Original processing happens in expand_password_confirm()
*/
function mymodule_process_password_confirm($element) {
// check if we the parent element is 'account'. On the user edit page, that is the case
// Of course, one could use arg() to check the path too
if ($element['#array_parents'][0] == 'account') {
$element['pass1']['#title'] = 'New password';
$element['pass2']['#title'] = 'Confirm new password';
}
return $element;
}
Please note this is based on Drupal 6.
In Drupal 7, hook_elements()
became hook_element_info because there is a proper alter hook, hook_element_info_alter