In addition to the normal single post view on my website, I added a full screen version of the post with entirely new set of styles. In this full screen option, everything is removed except the_content() of the post.

I did a functional non standard php template for this purpose called prompter.php and I put it in the root of my site.

In each single post, there is a button called "prompter view" that will trigger the view of the current post in "prompter mode" (full screen mode)

Everything is working OK, until I apply role based permission on my post.

It turns out my full screen mode is not being protected by the role permission set by wordpress.

My question is how can I make my custom post template inherit the permission set on the normal post template?

Here are the example of what I am trying to say.

Single post using normal template (unprotected)


Single post using full screen mode (unprotected)


Single post using normal template (Protected)


Single post using full screen mode (still unprotected)


It turns out that even there is a restriction imposed on post 2193, if the user will go straight to the fullscreen template and supply the post ID, the post will still be viewable without permission check.

How Can I make my full screen template protected also by WordPress permission settings?



The following bypasses wordpress by not going through index.php:


I'd recommend that instead of doing that, you place prompter.php in your theme directory and then hijack the page to display when someone clicks the link to view full screen using the template_redirect filter:

function my_special_display_view( $template ) {
    if ( is_page() && isset($_REQUEST['special_view']) ) {
        global $post;
        $post_id = $post->ID;
        $new_template = locate_template( array('prompter.php') );
        if ( !empty( $new_template ) ) {
            $template = $new_template;
    return $template;
add_filter( 'template_include', 'my_special_display_view', 99 );

This assumes a couple of things:

  1. Your links to your special view look like http://.../?p=2193&special_view=1
  2. Your prompter.php file uses wordpress internals to do things
  3. prompter.php is in the theme root directory

You might need to unenqueue your normal style sheet and queue up another in the same place that you do $template = $new_template;

add_action('wp_enqueue_scripts', 'do_change_styles_significantly', 11);

and a function to go with it:

function do_change_styles_significantly() {
    wp_dequeue_style( HOOK_FOR_YOUR_THEMES_STYLESHEET );
    wp_register_style( 'special_shiny', full_url_to_alternate_styles, array(), '1.0.0', 'all');

A bit more complicated, but it would be done within wordpress and give you what you are looking for.

  • Thanks. looks like this could work. I just need to clarify some things. I am using a child theme, shall I create the function on child theme function.php or the main theme function.php? I am assuming to put in child theme but I like to hear from expert if that is the best way. Also, my css on the full screen mode is all in-page and inline CSS, no external CSS, do I still need to unenqueue and queue? Jan 27 '15 at 8:10
  • Either theme should be fine, but if it is just for the child them I'd stick it in that themes functions.php file. If there are no style conflicts, you should not need to unenqueue anything. If there are, you might still need to unenqueue your theme styles though. If it is all inline, no need to enqueue anything (but it might be worth moving the styles out to make them more maintainable ... which would require enqueuing them)
    – Privateer
    Jan 27 '15 at 14:25
  • I tried but did not work. I am using child theme. I put your code in my child theme functions.php. then put prompter.php on my child theme root directory. When I visit [linl] (prompter.rareapps.org/aubrey/?prompterview=1) it still loads the default template. Feb 10 '15 at 12:46
  • 1
    work now. Thanks. the problem was you assumed I am using it on pages but it is for posts. so I just removed is_page() thanks Feb 10 '15 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.