hook_user
developer/hooks/core.php, строка 1459
- Версии
- 5 – 6
hook_user($op, &$edit, &$account, $category = NULL)
Выполняет действия с учётными записями пользователей.
Этот хук позволяет модулям взаимодействовать, когда операции выполняются с учётными записями пользователей.
Параметры
$op
Используется для описания текущей операции, выполняемой по отношению к учетной записи пользователя. Возможные значения:
'after_update'
: The user object has been updated and changed. Use this if (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 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.'submit'
: Modify the account before it gets saved.'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 toNULL
in$edit
.'login'
: The user just logged in.'logout'
: The user just logged out.'load'
: The user account is being loaded. The module may respond to this and insert additional information into the user object.'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.'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 toNULL
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.
$edit
The array of form values submitted by the user.
&$account
Объект пользователя, с которым выполняются операции.
$category
Активная категория информации о пользователе, которая редактируется.
Возвращаемое значение
This varies depending on the operation.
'categories'
: A linear array of associative arrays. These arrays have 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.
'submit'
: None:'insert'
: None.'update'
: None.'delete'
: None.'login'
: None.'logout'
: None.'load'
: None.'form'
,'register'
: A$form
array containing the form elements to display.'validate'
: None.'view'
: An associative array of associative arrays. The outer array should be keyed by category name. The interior array(s) should have a unique textual key and have'title'
,'value'
and'class'
elements. See theme_user_profile() and an example at user_user()
Связанные темы
Код
<?php
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;
}
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии