Is it possible to change the text field label from "Password" to " New Password" only in the Edit user profile page?

Not applicable

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 Solved
0 3 153
1 ACCEPTED 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...

1502-screen-shot-2015-11-19-at-95026-am.png

View solution in original post

3 REPLIES 3

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...

1502-screen-shot-2015-11-19-at-95026-am.png

Hi Anil,

Thanks for the reply!! It worked..

@saranya sekar , Awesome, Glad query is resolved 🙂