function hook_node_operations
Add mass node operations.
This hook enables modules to inject custom operations into the mass operations dropdown found at admin/content, 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 nodes.
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_node_operations()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- node_node_operations in modules/
node/ node.admin.inc - Implements hook_node_operations().
2 invocations of hook_node_operations()
- node_admin_nodes in modules/
node/ node.admin.inc - Form builder: Builds the node administration overview.
- node_admin_nodes_submit in modules/
node/ node.admin.inc - Process node_admin_nodes form submissions.
File
-
modules/
node/ node.api.php, line 422
Code
function hook_node_operations() {
$operations = array(
'publish' => array(
'label' => t('Publish selected content'),
'callback' => 'node_mass_update',
'callback arguments' => array(
'updates' => array(
'status' => NODE_PUBLISHED,
),
),
),
'unpublish' => array(
'label' => t('Unpublish selected content'),
'callback' => 'node_mass_update',
'callback arguments' => array(
'updates' => array(
'status' => NODE_NOT_PUBLISHED,
),
),
),
'promote' => array(
'label' => t('Promote selected content to front page'),
'callback' => 'node_mass_update',
'callback arguments' => array(
'updates' => array(
'status' => NODE_PUBLISHED,
'promote' => NODE_PROMOTED,
),
),
),
'demote' => array(
'label' => t('Demote selected content from front page'),
'callback' => 'node_mass_update',
'callback arguments' => array(
'updates' => array(
'promote' => NODE_NOT_PROMOTED,
),
),
),
'sticky' => array(
'label' => t('Make selected content sticky'),
'callback' => 'node_mass_update',
'callback arguments' => array(
'updates' => array(
'status' => NODE_PUBLISHED,
'sticky' => NODE_STICKY,
),
),
),
'unsticky' => array(
'label' => t('Make selected content not sticky'),
'callback' => 'node_mass_update',
'callback arguments' => array(
'updates' => array(
'sticky' => NODE_NOT_STICKY,
),
),
),
'delete' => array(
'label' => t('Delete selected content'),
'callback' => NULL,
),
);
return $operations;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.