Title: markfjb's Replies | WordPress.org

---

# markfjb

  [  ](https://wordpress.org/support/users/markfjb/)

 *   [Profile](https://wordpress.org/support/users/markfjb/)
 *   [Topics Started](https://wordpress.org/support/users/markfjb/topics/)
 *   [Replies Created](https://wordpress.org/support/users/markfjb/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/markfjb/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/markfjb/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/markfjb/engagements/)
 *   [Favorites](https://wordpress.org/support/users/markfjb/favorites/)

 Search replies:

## Forum Replies Created

Viewing 1 replies (of 1 total)

 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Retrieving filtered template name](https://wordpress.org/support/topic/retrieving-filtered-template-name/)
 *  Thread Starter [markfjb](https://wordpress.org/support/users/markfjb/)
 * (@markfjb)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/retrieving-filtered-template-name/#post-14110881)
 * Many thanks for the responses. I just realize that I probably should have been
   a bit more specific regarding my use case.
 * I am working on a website that is mostly only accessible once the user has logged
   in. There are however a few pages that are also visible when the user is not 
   logged in. For a subset of these I would like to use the default template when
   the user is logged in, but a different one when the user is not logged in. Thus
   the previously mentioned code or rather the conditional statement would be more
   specific, like:
 *     ```
       add_filter( 'template_include', 'special_page_template', 99 );
       function special_page_template( $template ) {
           if ( is_page( 'test' ) && !is_user_logged_in() ) {
               $new_template = locate_template( 'special-page.php' );
               return $new_template ;
           }
           return $template;
       }
       ```
   
 * In this case just changing the template in Admin or creating a specific page 
   template that will be used according to the template hierarchy won’t work.
 * I am working in a child theme and this function is in functions.php. I certainly
   can move this into a plugin, if this is the better place for such a function.
 * However I still have the problem that `is_page_template('special-page.php')` 
   doesn’t know about the switched template. I was wondering if there is a special
   function in WordPress to retrieve the template name that is actually in use, 
   after all possible filtering has been applied.
 * Hope this makes it more clear. Again sorry for not providing the full context
   from the start and apparently missing some essential details.

Viewing 1 replies (of 1 total)