My D7 customer uses the Workbench suite of modules to use taxonomy to allow fine-grained access to nodes successfully. But with a large amount of data to manage, sometimes they want to unpublish a node for the time being while keeping the data available in case they want to publish again. In Workbench, I've set up an "Archived" option which successfully renders that content unavailable to anonymous users. So when anonymous users visit that node, workbench, using hook_node_access() renders that node to NODE_ACCESS_DENY and it appears Drupal takes over and redirects the user to /user. That's good, but the customer wants to redirect back to root if they are anonymous. I thought about modifying Workbench using their API but it seems to be after stepping through how Drupal handles the menu_execute_handler() that the redirection to /user occurs. I need workbench to return the DENY so I can use that as one condition to dynamically alter how Drupal renders the view in a DENY situation. But I haven't found which part of core handles this redirection. Hunting through searches I found this suggestion which suggests to handle all 403s.
function my_module_menu() {
$items['403redirect'] = array(
'page callback' => 'mymodule_unpublished_redirect',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
function mymodule_unpublished_redirect() {
if (<TRUE>) {
header('location:'. url('/', array('absolute' => TRUE)), TRUE, 302);
}
}
But when visiting the node that is "Archived" redirects to /user which suggests that this function is ignored at this point. So how should I alter this redirect?