hook_user_insert

Versions
7
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 and set the saved fields to NULL in $edit.

See also

hook_user_presave()

@see hook_user_update()

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.

Related topics

Code

modules/user/user.api.php, line 242

<?php
function hook_user_insert(&$edit, $account, $category) {
  db_insert('mytable')
    ->fields(array(
      'myfield' => $edit['myfield'],
      'uid' => $account->uid,
    ))
    ->execute();
  // Inform user_save() to ignore the value of our property.
  $edit['myfield'] = NULL;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.