0

I need to send an email to a user who tried to register, but the registration failed due to some reason.

How can I do this? where do I hook into? I thought about it and searched for a while,

  • Hooking into hook_form_alter won't work because on submitting the form, I still don't know whether it would be a failed registration or not.
  • Hooking into hook_user_insert also won't work because this would only fire when the registration is successful.
3
  • on submitting the form, I still don't know whether it would be a failed registration or not Don't you? Beyond validation for the form failing, what do you class as "registration failed"?
    – Clive
    Commented Feb 12, 2018 at 13:14
  • registration failed could be because of username is already taken, could i make sure of this in form validation? Commented Feb 12, 2018 at 13:16
  • yes that gets checked in validation. I'm sure you can use $form_state->getErrors() to get existing ones in your own validation handler
    – Clive
    Commented Feb 12, 2018 at 13:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.