function change_pwd_page_form in Password Separate Form 7
Password change form.
1 string reference to 'change_pwd_page_form'
- change_pwd_page_menu in ./
change_pwd_page.module - Implements hook_menu().
File
- ./
change_pwd_page.module, line 75 - Provides the Password Change form in a separate page.
Code
function change_pwd_page_form($form, &$form_state, $account) {
global $user;
$register = $user->uid > 0 ? FALSE : TRUE;
// Get the currently logged in user object.
$form['#account'] = $account;
if (!isset($form_state['user'])) {
$form_state['user'] = $account;
}
else {
$account = $form_state['user'];
}
$form['#user'] = $account;
// Display password field only for existing users or when user is allowed to
// assign a password during registration.
if (!$register) {
// To skip the current password field, the user must have logged in via a
// one-time link and have the token in the URL.
$pass_reset = isset($_SESSION['pass_reset_' . $account->uid]) && isset($_GET['pass-reset-token']) && $_GET['pass-reset-token'] == $_SESSION['pass_reset_' . $account->uid];
$current_pass_description = '';
// The user may only change their own password without their current
// password if they logged in via a one-time login link.
if (!$pass_reset) {
$request_new = l(t('Request new password'), 'user/password', array(
'attributes' => array(
'title' => t('Request new password via e-mail.'),
),
));
$current_pass_description = t('Enter your current password to change the password. !request_new.', array(
'!request_new' => $request_new,
));
}
// The user must enter their current password to change to a new one.
$current_pass_disabled = variable_get('current_pass_disabled', FALSE);
if ($user->uid == $account->uid && !$current_pass_disabled) {
// Textfield for current password confirmation.
$form['current_pass'] = array(
'#type' => 'password',
'#title' => t('Current password'),
'#size' => 25,
'#required' => TRUE,
'#attributes' => array(
'autocomplete' => 'off',
),
'#access' => !$pass_reset,
'#description' => $current_pass_description,
);
if (!$pass_reset) {
$form['#validate'][] = 'change_pwd_page_validate_current_pass';
}
}
// Password confirm field.
$form['account']['pass'] = array(
'#type' => 'password_confirm',
'#size' => 25,
'#title' => t('New Password'),
'#required' => TRUE,
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}