Action Hook since 2.0.0

user_register

Fires immediately after a new user is registered

Description

user_register fires right after wp_insert_user() writes the row — the account exists but you're still inside the registration request, which matters for redirects and emails.

When it runs

Inside wp_insert_user(), after the user row and default meta are written.

Signature

do_action( 'user_register', int $user_id, array $userdata );

Parameters

  • $user_id int — ID of the newly registered user.
  • $userdata array — Raw array of user data used to create the account.

Examples

Basic

add_action( 'user_register', function( $user_id ) {
    $user = new WP_User( $user_id );
    $user->set_role( 'subscriber' );
    wp_mail( $user->user_email, 'Welcome!', 'Thanks for registering.' );
} );

Assign a default role and send a welcome email on signup.

Common Use Cases

  • Send welcome emails
  • Assign a default role
  • Sync new users to a CRM/mailing list
  • Set default user meta on signup

Common mistakes

  • Relying on this hook for social/SSO logins that create users a different way (some plugins bypass wp_insert_user)

Related hooks

FAQ

Does user_register fire for users created in wp-admin by an administrator?

Yes — any path that goes through wp_insert_user() triggers it, including admin-created accounts and REST API user creation.

Source: wp-includes/user.php

Group wizard

One session: this hook, then each related_hooks entry. Walk it and tell us what to change.

user_register → wp_login

functions.php — user_register
functions.php
PHP user_register · Hook 1 of 2 · Step 1 of 6

Practice the user_register WordPress action hook in our interactive sandbox — a VS Code-style editor with a step-by-step user_register tutorial, add_action exercises, and instant feedback. No local WordPress install required.