How to remove password and confirm password title from registration? I can find the name of both is ['pass[pass1]'] & ['pass[pass2]'] i wrote below code in template i am able to remove other name and email label
enter code here
function mysubtheme_form_alter(&$form, &$form_state, $form_id) {
$form['account']['name']['#title']= t('');
$form['account']['name']['#description']= t('');
$form['account']['name']['#attributes'] = array('placeholder' => t('USER NAME'));
$form['account']['mail']['#title'] = t('');
$form['account']['mail']['#description'] = t('');
$form['account']['mail']['#attributes'] = array('placeholder' => t('MAIL'));
$form['account']['conf_mail']['#title']= t('');
$form['account']['conf_mail']['#description']= t('');
$form['account']['conf_mail']['#attributes'] = array('placeholder' => t('CONFIRM EMAIL'));
$form['account']['pass[pass1]']['#title'] = t('');
$form['account']['pass[pass1]']['#description'] = t('');
$form['account']['pass[pass1]']['#attributes'] = array('placeholder' => t('PASSWORD'));
$form['account']['pass[pass2]']['#title'] = t('');
$form['account']['pass[pass2]']['#description'] = t('');
$form['account']['pass[pass2]']['#attributes'] = array('placeholder' => t('CONFIRM PASSWORD'));
}
To override the properties of the pass1
and pass2
, you need to add an additional #process
handler that runs after FAPI's form_process_password_confirm
, like so:
<?php
/**
* @file
* Allows modification of password fields in FAPI
*/
function register_alter_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'user_register_form':
// Here we need to provide an extra #process handler to allow us to modify
// the password element that FAPI expands.
$form['account']['pass']['#process'] = array('form_process_password_confirm', 'register_alter_password_confirm');
break;
}
}
/**
* Implementation of expand_password_confirm.
*/
function register_alter_password_confirm($element) {
$element['pass1']['#title'] = t("Password");
$element['pass2']['#title'] = t("Repeat password");
return $element;
}
?>
This snippet is changing the name of Password's and Confirm password's title. If you want to remove it, just simply add t("");
. If that's not working, you could also add a specific <span>
into it, and giving a display: none;
for it with CSS.
Hope that helps
(NOTE: For Drupal 6 change form_process_password_confirm
to expand_password_confirm
)