How can I set a Post's default visibility to private and pending review checked

there are 2 things I'd like to do:1. set a post's visibility to private by default.I've been looking aro

there are 2 things I'd like to do: 1. set a post's visibility to private by default.

I've been looking around the web for a code or even a plugin that lets me do this. The problem I've run into is that the codes no longer work.

  1. set the pending review checkbox to true as well?

If someone can point me in the right direction, Id appreciate it.

Thank you

there are 2 things I'd like to do: 1. set a post's visibility to private by default.

I've been looking around the web for a code or even a plugin that lets me do this. The problem I've run into is that the codes no longer work.

  1. set the pending review checkbox to true as well?

If someone can point me in the right direction, Id appreciate it.

Thank you

Share Improve this question asked Aug 4, 2019 at 15:03 junjijunji 213 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Found this snippet after more searching:

//Force posts of custom type to be private
//…but first make sure they are not 'trash' otherwise it is impossible to trash a post
function force_type_private($post)
{
    if (($post['post_type'] == 'post')

    {
    if ($post['post_status'] != 'trash') $post['post_status'] = 'private';
    }
    return $post;
}

add_filter('wp_insert_post_data', 'force_type_private');

Changed the boolean to:

if (($post['post_type'] == 'post')&&(!current_user_can('administrator')))

This makes sure only admin can publish.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745270044a4619688.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信