function hook_user
6.x core.php | hook_user($op, &$edit, &$account, $category = NULL) |
Act on user account actions.
This hook allows modules to react when operations are performed on user accounts.
Parameters
$op: What kind of action is being performed. Possible values (in alphabetical order):
- after_update: The user object has been updated and changed. Use this (probably along with 'insert') if you want to reuse some information from the user object.
- categories: A set of user information categories is requested.
- delete: The user account is being deleted. The module should remove its custom additions to the user object from the database.
- form: The user account edit form is about to be displayed. The module should present the form elements it wishes to inject into the form.
- insert: The user account is being added. The module should save its custom additions to the user object into the database and set the saved fields to NULL in $edit.
- load: The user account is being loaded. The module may respond to this and insert additional information into the user object.
- login: The user just logged in.
- logout: The user just logged out.
- register: The user account registration form is about to be displayed. The module should present the form elements it wishes to inject into the form.
- submit: Modify the account before it gets saved.
- update: The user account is being changed. The module should save its custom additions to the user object into the database and set the saved fields to NULL in $edit.
- validate: The user account is about to be modified. The module should validate its custom additions to the user object, registering errors as necessary.
- view: The user's account information is being displayed. The module should format its custom additions for display, and add them to the $account->content array.
$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.
Return value
This varies depending on the operation.
- categories: An array of associative arrays representing the categories
added by the implementing module. Each array can have the following
keys:
- name: The internal name of the category.
- title: The human-readable, localized name of the category.
- weight: An integer specifying the category's sort ordering.
- access callback: Name of a menu access callback function to use when editing this category. Defaults to using user_edit_access() if not specified. See hook_menu() for more information on menu access callbacks.
- access arguments: Arguments for the access callback function. Defaults to array(1) if not specified.
- delete: None.
- form, register: An array containing the form elements to add to the form.
- insert: None.
- load: None.
- login: None.
- logout: None.
- submit: None.
- update: None.
- validate: None.
- view: None.
Related topics
20 functions implement hook_user()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- block_user in drupal-6.x/
modules/ block/ block.module - Implementation of hook_user().
- blogapi_validate_user in drupal-6.x/
modules/ blogapi/ blogapi.module - Ensure that the given user has permission to edit a blog.
- blog_feed_user in drupal-6.x/
modules/ blog/ blog.pages.inc - Menu callback; displays an RSS feed containing recent blog entries of a given user.
- blog_page_user in drupal-6.x/
modules/ blog/ blog.pages.inc - Menu callback; displays a Drupal page containing recent blog entries of a given user.
- blog_user in drupal-6.x/
modules/ blog/ blog.module - Implementation of hook_user().
File
- documentation-6.x/
developer/ hooks/ core.php, line 2438 - These are the hooks that are invoked by the Drupal core.
Code
function hook_user($op, &$edit, &$account, $category = NULL) {
if ($op == 'form' && $category == 'account') {
$form['comment_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Comment settings'),
'#collapsible' => TRUE,
'#weight' => 4);
$form['comment_settings']['signature'] = array(
'#type' => 'textarea',
'#title' => t('Signature'),
'#default_value' => $edit['signature'],
'#description' => t('Your signature will be publicly displayed at the end of your comments.'));
return $form;
}
}