Title: user_register
Published: April 25, 2014
Last modified: February 24, 2026

---

# do_action( ‘user_register’, int $user_id, array $userdata )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/user_register/?output_format=md#parameters)
 * [More Information](https://developer.wordpress.org/reference/hooks/user_register/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/hooks/user_register/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/user_register/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/user_register/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/user_register/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/hooks/user_register/?output_format=md#wp--skip-link--target)

Fires immediately after a new user is registered.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/user_register/?output_format=md#parameters)󠁿

 `$user_id`int

User ID.

`$userdata`array

The raw array of data passed to [wp_insert_user()](https://developer.wordpress.org/reference/functions/wp_insert_user/).

More Arguments from wp_insert_user( … $userdata )

An array, object, or [WP_User](https://developer.wordpress.org/reference/classes/wp_user/)
object of user data arguments.

 * `ID` int
 * User ID. If supplied, the user will be updated.
 * `user_pass` string
 * The plain-text user password for new users.
    Hashed password for existing users.
 * `user_login` string
 * The user’s login username.
 * `user_nicename` string
 * The URL-friendly user name.
 * `user_url` string
 * The user URL.
 * `user_email` string
 * The user email address.
 * `display_name` string
 * The user’s display name.
    Default is the user’s username.
 * `nickname` string
 * The user’s nickname.
    Default is the user’s username.
 * `first_name` string
 * The user’s first name. For new users, will be used to build the first part of
   the user’s display name if `$display_name` is not specified.
 * `last_name` string
 * The user’s last name. For new users, will be used to build the second part of
   the user’s display name if `$display_name` is not specified.
 * `description` string
 * The user’s biographical description.
 * `rich_editing` string
 * Whether to enable the rich-editor for the user.
    Accepts `'true'` or `'false'`
   as a string literal, not boolean. Default `'true'`.
 * `syntax_highlighting` string
 * Whether to enable the rich code editor for the user.
    Accepts `'true'` or `'false'`
   as a string literal, not boolean. Default `'true'`.
 * `comment_shortcuts` string
 * Whether to enable comment moderation keyboard shortcuts for the user. Accepts`'
   true'` or `'false'` as a string literal, not boolean. Default `'false'`.
 * `admin_color` string
 * Admin color scheme for the user. Default `'fresh'`.
 * `use_ssl` bool
 * Whether the user should always access the admin over https. Default false.
 * `user_registered` string
 * Date the user registered in UTC. Format is ‘Y-m-d H:i:s’.
 * `user_activation_key` string
 * Password reset key. Default empty.
 * `spam` bool
 * Multisite only. Whether the user is marked as spam.
    Default false.
 * `show_admin_bar_front` string
 * Whether to display the Admin Bar for the user on the site’s front end. Accepts`'
   true'` or `'false'` as a string literal, not boolean. Default `'true'`.
 * `role` string
 * User’s role.
 * `locale` string
 * User’s locale. Default empty.
 * `meta_input` array
 * Array of custom user meta values keyed by meta key.
    Default empty.

## 󠀁[More Information](https://developer.wordpress.org/reference/hooks/user_register/?output_format=md#more-information)󠁿

This action hook allows you to access data for a new user immediately **after** 
they are added to the database. The user id is passed to hook as an argument.

Not all user meta data has been stored in the database when this action is triggered.
For example, nickname is in the database but first_name and last_name are not (as
of v3.9.1). The password has already been encrypted when this action is triggered.

Typically, this hook is used for saving additional user meta passed by custom registration
forms.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/user_register/?output_format=md#source)󠁿

    ```php
    do_action( 'user_register', $user_id, $userdata );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/user.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/user.php#L2654)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/user.php#L2654-L2654)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/user_register/?output_format=md#related)󠁿

| Used by | Description | 
| [wp_insert_user()](https://developer.wordpress.org/reference/functions/wp_insert_user/)`wp-includes/user.php` |

Inserts a user into the database.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/user_register/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.8.0](https://developer.wordpress.org/reference/since/5.8.0/) | The `$userdata` parameter was added. | 
| [1.5.0](https://developer.wordpress.org/reference/since/1.5.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/user_register/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 4 content](https://developer.wordpress.org/reference/hooks/user_register/?output_format=md#comment-content-4257)
 2.    [Steven Lin](https://profiles.wordpress.org/stevenlinx/)  [  6 years ago  ](https://developer.wordpress.org/reference/hooks/user_register/#comment-4257)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fuser_register%2F%23comment-4257)
     Vote results for this note: 5[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fuser_register%2F%23comment-4257)
 4.  Example migrated from Codex:
 5.  This example will save a `first_name` field passed by a custom registration field.
 6.  Also, keep in mind that validation of registration fields should not be performed
     within this hook! Validate using the [`registration_errors`](https://developer.wordpress.org/reference/hooks/registration_errors/)
     hook instead (the `user_register` hook will not be called if `registration_errors`
     validation fails).
 7.      ```php
         add_action( 'user_register', 'myplugin_registration_save', 10, 1 );
     
         function myplugin_registration_save( $user_id ) {
     
             if ( isset( $_POST['first_name'] ) )
                 update_user_meta($user_id, 'first_name', $_POST['first_name']);
     
         }
         ```
     
 8.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fuser_register%2F%3Freplytocom%3D4257%23feedback-editor-4257)
 9.   [Skip to note 5 content](https://developer.wordpress.org/reference/hooks/user_register/?output_format=md#comment-content-4470)
 10.   [Omid Beheshtian](https://profiles.wordpress.org/omidbeheshtian/)  [  5 years ago  ](https://developer.wordpress.org/reference/hooks/user_register/#comment-4470)
 11. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fuser_register%2F%23comment-4470)
     Vote results for this note: 3[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fuser_register%2F%23comment-4470)
 12. We can use this php code to **update database** from
      own **custom register field.**
 13.     ```php
         add_action( 'user_register', function ( $user_id ) {
             $userdata = array();
             $userdata['ID'] = $user_id;
             $userdata['telnumber'] = $_POST['telnumber'];
             wp_update_user( $userdata );
         } );
         ```
     
 14.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fuser_register%2F%3Freplytocom%3D4470%23feedback-editor-4470)
 15.  [Skip to note 6 content](https://developer.wordpress.org/reference/hooks/user_register/?output_format=md#comment-content-7161)
 16.   [Armin Amiri Nasab](https://profiles.wordpress.org/arminamirinasab/)  [  2 years ago  ](https://developer.wordpress.org/reference/hooks/user_register/#comment-7161)
 17. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fuser_register%2F%23comment-7161)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fuser_register%2F%23comment-7161)
 18. In this code we send an email when user register at our site:
 19.     ```php
         add_action( 'user_register', function ( $userID, $userData ) {
             wp_mail( $userData['user_email'], __( 'Welcome' ) . ' ' . $userData['nickname'], __( 'Welcome to our site :)' ) );
         }, 10, 2 );
         ```
     
 20.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fuser_register%2F%3Freplytocom%3D7161%23feedback-editor-7161)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fuser_register%2F)
before being able to contribute a note or feedback.