Reputation: 15456
This is on Drupal 7. I have some content I want to 'hide' (as opposed to publish/unpublish) from anonymous users.
Someone has made a check box ($hidden_value
) to do this already, but it's redirecting to 403.
$access = !$hidden_value['value'] ? user_access('access content') : !user_is_anonymous();
I want to make this redirect to the 404 page and so within hook_preprocess_page()
I added:
if ($access === FALSE) {
drupal_not_found();
}
but this does not seem to work - It still redirects to 403. I also tried drupal_exit
to the same result.
Would anyone know what I can do to fix this?
Upvotes: 1
Views: 872
Reputation: 304
You can use hook_node_view()
function hook_node_view($node, $view_mode) {
if (!user_is_logged_in()){
drupal_not_found();
}
}
https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_view/7.x
Upvotes: 1