Using WordPress ‘handle_network_bulk_actions-{$screen}’ PHP filter

The handle_network_bulk_actions-{$screen} WordPress PHP filter fires when a custom bulk action should be handled. It modifies the redirect link with success or failure feedback from the action to be used to display feedback to the user. The dynamic portion of the hook name, $screen, refers to the current screen ID.

Usage

add_filter('handle_network_bulk_actions-your_screen_id', 'your_custom_function', 10, 4);

function your_custom_function($redirect_url, $action, $items, $site_id) {
    // your custom code here
    return $redirect_url;
}

Parameters

  • $redirect_url (string) – The redirect URL.
  • $action (string) – The action being taken.
  • $items (array) – The items to take the action on.
  • $site_id (int) – The site ID.

More information

See WordPress Developer Resources: handle_network_bulk_actions-{$screen}

Examples

Custom Delete Action

Delete multiple items with a custom delete action.

add_filter('handle_network_bulk_actions-your_screen_id', 'custom_bulk_delete', 10, 4);

function custom_bulk_delete($redirect_url, $action, $items, $site_id) {
    if ($action == 'delete_items') {
        foreach ($items as $item_id) {
            // Perform delete operation on the item
        }
        // Modify the redirect URL to display success message
    }
    return $redirect_url;
}

Custom Publish Action

Publish multiple posts with a custom publish action.

add_filter('handle_network_bulk_actions-your_screen_id', 'custom_bulk_publish', 10, 4);

function custom_bulk_publish($redirect_url, $action, $items, $site_id) {
    if ($action == 'publish_posts') {
        foreach ($items as $post_id) {
            // Perform publish operation on the post
        }
        // Modify the redirect URL to display success message
    }
    return $redirect_url;
}

Custom Deactivate Action

Deactivate multiple plugins with a custom deactivate action.

add_filter('handle_network_bulk_actions-your_screen_id', 'custom_bulk_deactivate', 10, 4);

function custom_bulk_deactivate($redirect_url, $action, $items, $site_id) {
    if ($action == 'deactivate_plugins') {
        foreach ($items as $plugin) {
            // Perform deactivate operation on the plugin
        }
        // Modify the redirect URL to display success message
    }
    return $redirect_url;
}

Custom Activate Action

Activate multiple plugins with a custom activate action.

add_filter('handle_network_bulk_actions-your_screen_id', 'custom_bulk_activate', 10, 4);

function custom_bulk_activate($redirect_url, $action, $items, $site_id) {
    if ($action == 'activate_plugins') {
        foreach ($items as $plugin) {
            // Perform activate operation on the plugin
        }
        // Modify the redirect URL to display success message
    }
    return $redirect_url;
}

Custom Update Action

Update multiple items with a custom update action.

add_filter('handle_network_bulk_actions-your_screen_id', 'custom_bulk_update', 10, 4);

function custom_bulk_update($redirect_url, $action, $items, $site_id) {
    if ($action == 'update_items') {
        foreach ($items as $item_id) {
            // Perform update operation on the item
        }
    // Modify the redirect URL to display success message
    }
    return $redirect_url;
}