If you need to stop registration based on custom business logic (e.g., checking an external blacklist), use a custom validation handler via hook_form_alter .
Do you need help on the registration form, or are you looking to redirect users after they sign up? drupal-8-user-register-hook
Inside presave , always call $user->isNew() to ensure your code only runs during initial registration rather than every time a profile is updated. If you need to stop registration based on
For cleaner, decoupled code, consider Symfony Event Subscribers if you are using the Hook Event Dispatcher module. Use this for actions that require the new
This is the standard approach to identify a vs. an existing user being updated.
Use this for actions that require the new User ID, like sending a custom welcome email or creating related profile entries. Modifies the registration form .
The most effective way to intercept or modify user data during registration is through the following hooks: Usage Note Runs before the user is saved.