Drupal-8-user-register-hook -

Use this to add custom fields or validation logic (e.g., matching a secondary database). πŸ’» Code Example: hook_user_presave

[Solved] How to hook into Commerce after payment complete - Drupal drupal-8-user-register-hook

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 Use this to add custom fields or validation logic (e

This is the standard approach to identify a vs. an existing user being updated. set a field value $user->set('field_welcome_status'

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 .