I have two pages on my site (created using views) that I would like to hide from anonymous users by redirecting them to a custom access denied page. i.e. If an anonymous user tries to go to the page "wolfdogs/deceased" they are redirected to "access-denied". I found this bit of php that looks promising:
if (in_array('anonymous user', array_values($user->roles))) {
$dest = $_SERVER['REQUEST_URI'];
$dest = substr($dest,1); //this removes preceding slash from string
$path[]='vote'; //example paths to hide from anonymous users...
$path[]='volunteer';
$path[]='papers-list';
$path[]='event-register';
$path[]='replays-list';
$path[]='how-to-upgrade';
$path[]='membership-renewal';
if (in_array($dest, $path)) {
return drupal_goto('members-only'); //this line re-directs to custom access denied page.
}
}
Ideally I would like put this into a block, and then put the block on the "hidden" pages. However, it was written for Drupal 6; I don't if it works with Drupal 7, and I am unsure how to implement it into a block.