Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
    
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

3 Answers 3

up vote 3 down vote accepted

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.

share|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.

share|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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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