title: adding custom page template from plugin
body: <p>I'm working on building my first plugin for wordpress and am needing it to dynamically add a custom page for a login screen among other things.</p>
  
  <p>The only thing I've been able to find that's anywhere near what I'm needing is here: <a href="https://stackoverflow.com/questions/4647604/wp-use-file-in-plugin-directory-as-custom-page-template">WP - Use file in plugin directory as custom Page Template?</a> &amp; <a href="http://themeforest.net/forums/thread/possible-to-add-custom-template-page-in-a-wp-plugin-/71159?page=1#907423" rel="nofollow noreferrer">Possible to add Custom Template Page in a WP plugin?</a>, but they're still not quite what I'm looking for.</p>
  
  <p>Here is the code that I currently have running in my plugin...</p>
  
  <pre><code>// Add callback to admin menu
  add_action( 'template_redirect', 'uploadr_redirect' );
  
  // Callback to add menu items
  function uploadr_redirect() {
  
  global $wp;
  $plugindir = dirname( __FILE__ );
  
  // A Specific Custom Post Type
  if ( $wp-&gt;query_vars["post_type"] == 'uploadr' ) {
  
      $templatefilename = 'custom-uploadr.php';
  
      if ( file_exists( TEMPLATEPATH . '/' . $templatefilename )) {
  
          $return_template = TEMPLATEPATH . '/' . $templatefilename;
  
      } else {
  
          $return_template = $plugindir . '/themefiles/' . $templatefilename;
  
      }
  
      do_theme_redirect( $return_template );
  
  }
  
  }
  
  
  function do_theme_redirect( $url ) {
  
      global $post, $wp_query;
  
      if ( have_posts ()) {
  
          include( $url );
          die();
  
      } else {
  
          $wp_query-&gt;is_404 = true;
  
      }
  
  }
  </code></pre>
  
  <p>Using this would require that my client create new page... what I'm needing is for the pluging to auto create a custom page (with a customized path, meaning .com/custompathhere) using a template file from the plugin folder, which will then contain all actions the plugin performs.</p>
  
  <p>Note: This plugin is designed to run on one page, therefore reducing load-time and etc.</p>
  
  <p>Thanks in advance!</p>