This turned out to be far easier than I had feared, using the template_include
filter –
/**
* Override the standard WordPress template with the 'please login' template if the current user is not logged in
*/
add_filter('template_include', 'portfolio_page_template', 99);
function portfolio_page_template($template){
/** List the pages that are authorised for non-logged in users */
$authorised_pages = array(
get_site_url().'/login/',
get_site_url().'/wp-login.php'
);
/** Ensure that the user is actually NOT logged in */
if(!is_user_logged_in()) :
/** Ensure we are not trying to view an $authorised page (to avoid a loop) */
if(!in_array($url, $authorised_pages)) :
/** Setup the new template */
$new_template = locate_template(array('login-page.php'));
if($new_template !== '') :
return $new_template ;
endif;
endif;
endif;
return $template;
}