If I set a page to private, can I have it show a message instead of a 404 page for public users?
3 Answers
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.
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.
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.
'private' == 404
result and so far have not been able to make it work.