Drupal-8-user-register-hook | 2024-2026 |

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

Do you need help on the registration form, or are you looking to redirect users after they sign up? 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 This is the standard approach to identify a vs

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

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 .

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

Do you need help on the registration form, or are you looking to redirect users after they sign up?

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

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 User ID, like sending a custom welcome email or creating related profile entries. Modifies the registration form .