function rpt_form_user_register_form_alter in Registration Password Token 8
Implements hook_form_FORM_ID_alter().
File
- ./
rpt.module, line 53 - Registration Password Token module.
Code
function rpt_form_user_register_form_alter(&$form, FormStateInterface $form_state) {
$settings = \Drupal::config('rpt.settings');
// Hide password field and generate password for user.
$generate_password = $settings
->get('password_generate');
if ($generate_password) {
$form['account']['pass']['#type'] = 'value';
$password_length = $settings
->get('password_length');
$form['account']['pass']['#value'] = user_password($password_length);
}
}