| 7 user.api.php | hook_user_insert(& |
| 8 user.api.php | hook_user_insert($account) |
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
Related topics
4 functions implement hook_user_insert()
2 invocations of hook_user_insert()
File
- modules/
user/ user.api.php, line 250 - 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();
}
Login or register to post comments
Comments
Can this be used to emulate 'access rules' in Drupal 7?
Is there an easier way to, for example, block all users that do not have email addresses from a certain institution?
Edit: Found the Rules module does it. Sorry for the spam, folks.
RULES :D omg, great idea ;)
RULES :D omg, great idea ;) thx
question on 'user' vs 'account'
I'm relatively clueless about php but trying to add a subscription for all new users, and finding a problem: if admin adds a user, then the $account value is admin. Is it possible to grab or construct the new user object from the $edit object? Does it exist at this point?