admin管理员组

文章数量:1319479

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?

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?

Share Improve this question edited Sep 18, 2013 at 20:52 jjeaton asked Sep 18, 2013 at 18:14 jjeatonjjeaton 2,2072 gold badges25 silver badges37 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 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.

IIRC it's if a post is password protected.

本文标签: coreWhat is a quotprotectedquot post status