do_action( 'user_register', int $user_id , array $userdata )
Fires immediately after a new user is registered.
Parameters
- $user_id
-
(int) User ID.
- $userdata
-
(array) The raw array of data passed to wp_insert_user().
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
File: wp-includes/user.php
Changelog
Version | Description |
---|---|
5.8.0 | The $userdata parameter was added. |
1.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
Example migrated from Codex:
This example will save a
first_name
field passed by a custom registration field.Also, keep in mind that validation of registration fields should not be performed within this hook! Validate using the
registration_errors
hook instead (theuser_register
hook will not be called ifregistration_errors
validation fails).We can use this php code to update database from
own custom register field.