Skip to content
Snippets Groups Projects

Issues/2980952: Update message on cancelling account with e-mail confirmation request.

Closed AKHIL BABU requested to merge issue/drupal-2980952:2980952-wrong-message-on into 11.x
2 unresolved threads
Files
2
@@ -149,9 +149,14 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity->user_cancel_notify = $form_state->getValue('user_cancel_notify');
$this->entity->save();
_user_mail_notify('cancel_confirm', $this->entity);
$this->messenger()->addStatus($this->t('A confirmation request to cancel your account has been sent to your email address.'));
$this->logger('user')->info('Sent account cancellation request to %name %email.', ['%name' => $this->entity->label(), '%email' => '<' . $this->entity->getEmail() . '>']);
$cancel_message = $this->t('A confirmation request to cancel your account has been sent to your email address.');
if ($this->entity->id() !== $this->currentUser()->id()) {
$cancel_message = $this->t("A confirmation request to cancel the account %name has been sent to the user's email address.", ['%name' => $this->entity->label()]);
}
    • Comment on lines +154 to +160

      any chance we can simplify? The action taken is the same in both branches of the condition, no need to duplicate it, just need to change the message in some cases.

      Suggested change
      Applied
      151 $messenger = $this->messenger();
      152 if ($this->entity->id() == $this->currentUser()->id()) {
      153 $messenger->addStatus($this->t('A confirmation request to cancel your account has been sent to your email address.'));
      154 }
      155 else {
      156 $messenger->addStatus($this->t("A confirmation request to cancel the account %name has been sent to the user's email address.", ['%name' => $this->entity->label()]));
      157 }
      151 $cancel_message = $this->t('A confirmation request to cancel your account has been sent to your email address.');
      152 if ($this->entity->id() !== $this->currentUser()->id()) {{
      153 $cancel_message = $this->t("A confirmation request to cancel the account %name has been sent to the user's email address.", ['%name' => $this->entity->label()]);
      154 }
      155 $this->messenger()->addStatus($cancel_message);
      Edited by Théodore Biadala
Please register or sign in to reply
$this->messenger()->addStatus($cancel_message);
$form_state->setRedirect(
'entity.user.canonical',
['user' => $this->entity->id()]
Loading