You are here

function hook_user_operations in Drupal 7

Add mass user operations.

This hook enables modules to inject custom operations into the mass operations dropdown found at admin/people, by associating a callback function with the operation, which is called when the form is submitted. The callback function receives one initial argument, which is an array of the checked users.

Return value

An array of operations. Each operation is an associative array that may contain the following key-value pairs:

  • "label": Required. The label for the operation, displayed in the dropdown menu.
  • "callback": Required. The function to call for the operation.
  • "callback arguments": Optional. An array of additional arguments to pass to the callback function.

Related topics

1 function implements hook_user_operations()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

user_user_operations in modules/user/user.module
Implements hook_user_operations().
2 invocations of hook_user_operations()
user_admin_account in modules/user/user.admin.inc
Form builder; User administration page.
user_admin_account_submit in modules/user/user.admin.inc
Submit the user administration update form.

File

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

Code

function hook_user_operations() {
  $operations = array(
    'unblock' => array(
      'label' => t('Unblock the selected users'),
      'callback' => 'user_user_operations_unblock',
    ),
    'block' => array(
      'label' => t('Block the selected users'),
      'callback' => 'user_user_operations_block',
    ),
    'cancel' => array(
      'label' => t('Cancel the selected user accounts'),
    ),
  );
  return $operations;
}