Handle multiple parameters in filter

The problem is that you use apply_filters incorrectly.

This function takes at least two parameters:

  • $tag
    (string) (Required) The name of the filter hook
  • $value
    (mixed) (Required) The value on which the filters hooked to $tag are applied on.

So the first param should be the name of the hook and as second param you should always pass the value of filter. If you want to use any other params, you have to pass them later.

So in your case it should look like this:

function FILTER_HOOK(array $items, $block_id)
{
  // How can I pass both parameters to the next hook?
  return $items;
}
add_filter('HOOK_NAME', 'FILTER_HOOK', 10, 2);

apply_filters('HOOK_NAME', $items, 'BLOCK_ID');

add_filter('HOOK_NAME', function (array $items, $block_id) {
  if ($block_id == 'MY_BLOCK') {
    return array(
      'A' => 1,
    );
  }
  return $items; // filter should always return some value
}, 10, 2);