You are here

public function LogintobogganProfileForm::save in LoginToboggan 8

Save form.

Overrides ProfileForm::save

File

src/Form/LogintobogganProfileForm.php, line 91

Class

LogintobogganProfileForm
LogintobogganProfileForm.

Namespace

Drupal\logintoboggan\Form

Code

public function save(array $form, FormStateInterface $form_state) {
  $currentuser = \Drupal::currentUser();
  if ($currentuser
    ->hasPermission('administer users')) {
    $build = $form_state
      ->getBuildInfo();
    $trusted = $build['logintoboggan_trusted'];
    $trusted_role = LogintobogganUtility::trustedRole();
    $account = $form_state
      ->getFormObject()
      ->getEntity();
    $new_roles = $form_state
      ->getValue('roles');
    if (in_array($trusted_role, $new_roles) && $trusted == '0') {
      _user_mail_notify('status_activated', $account);
    }
  }
  parent::save($form, $form_state);
}