I need to change the text field label name from "Password" to "New Password" only in the Edit User Profile page , without affecting all the other pages like Register form?Because "Password" is the label name which is being used consistently in all the pages.
Solved! Go to Solution.
Dear @saranya sekar ,
Yes, It's possible. You need to build a small custom module to achieve this. You will implement hook_form_alter hook in drupal to achieve this. See code below.
function MYMODULE_form_alter(&$form, &$form_state, $form_id) { if($form_id == 'user_profile_form'){ // Here we need to provide an extra #process handler to allow us to modify // the password element that FAPI expands. $element_info = element_info('password_confirm'); $process = $element_info['#process']; $process[] = 'MYMODULE_process_password_confirm'; $form['account']['pass']['#process'] = $process; } } function MYMODULE_process_password_confirm($element) { $element['pass1']['#title'] = t("New Password"); $element['pass2']['#title'] = t("Confirm New Password"); return $element; }
Change MYMODULE to your custom module name...
Dear @saranya sekar ,
Yes, It's possible. You need to build a small custom module to achieve this. You will implement hook_form_alter hook in drupal to achieve this. See code below.
function MYMODULE_form_alter(&$form, &$form_state, $form_id) { if($form_id == 'user_profile_form'){ // Here we need to provide an extra #process handler to allow us to modify // the password element that FAPI expands. $element_info = element_info('password_confirm'); $process = $element_info['#process']; $process[] = 'MYMODULE_process_password_confirm'; $form['account']['pass']['#process'] = $process; } } function MYMODULE_process_password_confirm($element) { $element['pass1']['#title'] = t("New Password"); $element['pass2']['#title'] = t("Confirm New Password"); return $element; }
Change MYMODULE to your custom module name...
Hi Anil,
Thanks for the reply!! It worked..
@saranya sekar , Awesome, Glad query is resolved 🙂