If I set a page to private, can I have it show a message instead of a 404 page for public users?

  • I have in the past (due to another question here) attempted to get around the 'private' == 404 result and so far have not been able to make it work. – s_ha_dum Jun 13 '13 at 21:27

This is challenging, because showing something would require page not to be private.

It is more common to leave page public, but make it produce conditional output depending on if user is logged (is_user_logged_in()) in or other criteria.

| improve this answer | |

I agree with Rarst. Unless you use conditional output you'll need to figure out how to undo what the Core does with urls for Posts that are private. Otherwise a user that is not logged in will get the 404.

Going with is_user_logged_in() will take care of what you need it to.

| improve this answer | |

I'm using this:

if ( current_user_can('read_private_pages') )

With this condition, only Administrators and Editors can view the content of the page.

| improve this answer | |

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.