You are here

function hook_group_operations in Group 7

Add mass group operations.

This hook enables modules to inject custom operations into the mass operations dropdown found at admin/group 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 selected group ids. If it is a form callback, it receives the form and form state as well.

Return value

array 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.
  • form callback: (optional) Whether the callback is a form builder. Set to TRUE to have the callback build a form such as a confirmation form. This form will then replace the group overview form, see the 'delete' operation for an example.
  • optgroup: (optional) The label of the <optgroup> this operation should be placed under. This will put the operation in the same <optgroup> as all other operations that specify the same label.
1 function implements hook_group_operations()

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

group_group_operations in ./group.group.inc
Implements hook_group_operations().
2 invocations of hook_group_operations()
group_options_form in admin/group.inc
Builds the group administration options.
group_options_form_submit in admin/group.inc
Options form submit callback.

File

./group.api.php, line 169
Hooks provided by the Group module.

Code

function hook_group_operations() {

  // Acts upon selected groups but shows overview form right after.
  $operations['close'] = array(
    'label' => t('Close selected groups'),
    'callback' => 'mymodule_open_or_close_groups',
    'callback arguments' => array(
      'close',
    ),
    'optgroup' => t('Open or close'),
  );

  // Acts upon selected groups but shows overview form right after.
  $operations['open'] = array(
    'label' => t('Open selected groups'),
    'callback' => 'mymodule_open_or_close_groups',
    'callback arguments' => array(
      'open',
    ),
    'optgroup' => t('Open or close'),
  );

  // Shows a different form when this operation is selected.
  $operations['delete'] = array(
    'label' => t('Delete selected groups'),
    'callback' => 'group_multiple_delete_confirm',
    'form callback' => TRUE,
  );
  return $operations;
}