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 Arguments from wp_insert_user( ... $userdata )
An array, object, or WP_User object of user data arguments.
ID
intUser ID. If supplied, the user will be updated.user_pass
stringThe plain-text user password for new users.
Hashed password for existing users.user_login
stringThe user's login username.user_nicename
stringThe URL-friendly user name.user_url
stringThe user URL.user_email
stringThe user email address.display_name
stringThe user's display name.
Default is the user's username.nickname
stringThe user's nickname.
Default is the user's username.first_name
stringThe 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
stringThe 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
stringThe user's biographical description.rich_editing
stringWhether to enable the rich-editor for the user.
Accepts'true'
or'false'
as a string literal, not boolean. Default'true'
.syntax_highlighting
stringWhether to enable the rich code editor for the user.
Accepts'true'
or'false'
as a string literal, not boolean. Default'true'
.comment_shortcuts
stringWhether to enable comment moderation keyboard shortcuts for the user. Accepts'true'
or'false'
as a string literal, not boolean. Default'false'
.admin_color
stringAdmin color scheme for the user. Default'fresh'
.use_ssl
boolWhether the user should always access the admin over https. Default false.user_registered
stringDate the user registered in UTC. Format is 'Y-m-d H:i:s'.user_activation_key
stringPassword reset key. Default empty.spam
boolMultisite only. Whether the user is marked as spam.
Default false.show_admin_bar_front
stringWhether 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
stringUser's role.locale
stringUser's locale. Default empty.meta_input
arrayArray of custom user meta values keyed by meta key.
Default empty.
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
.
View all references
do_action( 'user_register', $user_id, $userdata );
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.