You are here

function force_password_change_insert_user in Force Password Change 2.0.x

Same name and namespace in other branches
  1. 8 force_password_change.module \force_password_change_insert_user()
1 string reference to 'force_password_change_insert_user'
force_password_change_form_alter in ./force_password_change.module
Implements hook_form_alter().

File

./force_password_change.module, line 292

Code

function force_password_change_insert_user(array $form, FormStateInterface $form_state) {
  if ($form_state
    ->getValue('force_password_change')) {
    $uid = $form_state
      ->getValue('uid');
    $force_password_change_service = \Drupal::service('force_password_change.service');
    $force_password_change_service
      ->forceUserPasswordChange($uid);
    $force_password_change_service
      ->addFirstTimeLogin($uid);
    \Drupal::messenger()
      ->addMessage(t('%name will be required to change their password upon their first login', [
      '%name' => $form_state
        ->getValue('name'),
    ]));
  }
}