What is a “protected” post status?

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.

Read More

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?

Related posts

2 comments

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

Comments are closed.