You can create a page after your plugin is activated. Take a look at this:
register_activation_hook( __FILE__, 'insert_page' );
function insert_page(){
$my_page = array(
'post_title' => 'My Page',
'post_name' => 'MyPage',
'post_content' => 'My page's content.',
'post_status' => 'publish',
'post_author' => get_current_user_id(),
'post_type' => 'page',
);
wp_insert_post( $my_page, '' );
}
Then assign your template file to your custom page:
add_filter( 'page_template', 'my_custom_page' );
function my_custom_page( $page_template )
{
if ( is_page( 'MyPage' ) ) {
$page_template = plugin_dir_path( __FILE__ ) . '/MyPage.php';
}
return $page_template;
}
Now, you have your page and your template. In your template, use this code to detect the visitor’s status and decide to redirect them or not:
<?php
if (!is_user_logged_in()) {
wp_safe_redirect( site_url('/wp-login.php'));
exit;
}
?>
After this code you can safely output your content, since the user will be redirected before outputting the content if he/she is not logged in.
Let me know if you need further assistance.