WordPress.org

Ready to get started?Download WordPress

Codex

Plugin API/Action Reference/user register

Contents

Description

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.

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

Example

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 (the user_register hook will not be called if registration_errors validation fails).

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']);

}

Source File

user_register is located in /wp-includes/user.php within the function wp_insert_user()

Related

Tutorials

Action Hooks

Filter Hooks

Return to Plugin API/Action Reference