7

I noticed in the register_post_status function in core that there is an arg for 'protected'.

The following post statuses: 'future', 'draft', and 'pending' all have this set to true.

I'm not talking about a protected 'post' but the 'protected' argument used when registering a custom post_status.

What does this 'protected' status do? And why would I make a custom post status protected?

2 Answers 2

14

register_post_status is used for creating a custom post status. The protected argument, if true, specifies that a user must be logged in and have edit permissions on the post to view (preview) it.

For example, you said that the "draft" post status has protected set to true. This means that you can only view (preview) the draft post if you have permission to edit the post. Once the post is published, the protected parameter is turned off and anyone can view it.

If you are creating your own custom status, you might want it to be protected. For example, you could have a post status called "on_hold", and when you set a post to that status, it would no longer be visible to the public, but still visible to the administrators of your site.

0
1

IIRC it's if a post is password protected.

2
  • 1
    Correct. You can set a password on a page, but still have it accessible without someone logging in - they just need to know the password. Sep 18, 2013 at 18:45
  • 4
    I think it's unrelated to password protected posts. The 'protected' argument is used in register_post_status. It's related to a post status, not an individual post. If that were true, then I would think that all 'future', 'draft' and 'pending' posts would all be password protected.
    – jjeaton
    Sep 18, 2013 at 20:50

Your Answer

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

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