You are here

function hook_group_member_operations in Group 7

Add mass group member operations.

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

Parameters

Group $group: The group to show member operations for.

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 member 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.

See also

group_member_options_form()

2 functions implement hook_group_member_operations()

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

ggroup_group_member_operations in modules/ggroup/ggroup.group.inc
Implements hook_group_member_operations().
group_group_member_operations in ./group.group.inc
Implements hook_group_member_operations().
2 invocations of hook_group_member_operations()
group_member_options_form in admin/group_membership.inc
Builds the group member administration options.
group_member_options_form_submit in admin/group_membership.inc
Options form submit callback.

File

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

Code

function hook_group_member_operations(Group $group) {

  // Acts upon selected members but shows overview form right after.
  $operations['block'] = array(
    'label' => t('Block selected members'),
    'callback' => 'mymodule_block_members',
  );

  // Shows a different form when this operation is selected.
  $operations['remove'] = array(
    'label' => t('Remove selected members'),
    'callback' => 'group_membership_multiple_delete_confirm',
    'form callback' => TRUE,
  );
  return $operations;
}