Skip navigation
Help

hook_user_insert

7 user.api.php hook_user_insert(&$edit, $account, $category)

A user account was created.

The module should save its custom additions to the user object into the database.

Parameters

$edit: The array of form values submitted by the user.

$account: The user object on which the operation is being performed.

$category: The active category of user information being edited.

See also

hook_user_presave()

hook_user_update()

Related topics

4 functions implement hook_user_insert()

4 invocations of hook_user_insert()

File

drupal/modules/user/user.api.php, line 249
Hooks provided by the User module.

Code

function hook_user_insert(&$edit, $account, $category) {
  db_insert('mytable')
    ->fields(array(
    'myfield' => $edit['myfield'], 
    'uid' => $account->uid,
  ))
    ->execute();
}