Drupal-8-user-register-hook <Must Read>

This is the standard approach to identify a vs. an existing user being updated.

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. drupal-8-user-register-hook

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 . This is the standard approach to identify a vs

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 . If you need to stop registration based on

To hook into the user registration process in Drupal 8 (and 9/10+), you typically use entity hooks since users are treated as content entities. 🛠️ Recommended Hooks

[Solved] How to hook into Commerce after payment complete - Drupal

use Drupal\user\UserInterface; /** * Implements hook_ENTITY_TYPE_presave() for user entities. */ function my_module_user_presave(UserInterface $user) { // Check if this is a new user registration if ($user->isNew()) { // Perform custom logic, e.g., set a field value $user->set('field_welcome_status', 'Pending'); } } Use code with caution. Copied to clipboard 🎯 Key Considerations