2

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

1
  • 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
    Commented Jun 13, 2013 at 21:27

3 Answers 3

4

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.

0

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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