您的当前位置:首页 > 知识博客 > wordpress建站

WordPress生成文章类型角色权限函数:get_post_type_capabilities

时间:2024-03-10

WordPress函数get_post_type_capabilities用于快速生成文章类型角色权限。

get_post_type_capabilities( object $args )

函数参数

$args

对象

参考register_post_type()函数的参数说明,必须的参数:capability_type、capabilities、map_meta_cap

函数返回值

stdClass Object
(
    [edit_post] => edit_post
    [read_post] => read_post
    [delete_post] => delete_post
    [edit_posts] => edit_posts
    [edit_others_posts] => edit_others_posts
    [delete_posts] => delete_posts
    [publish_posts] => publish_posts
    [read_private_posts] => read_private_posts
    [create_posts] => edit_posts
)

函数使用示例

$args = array(
	'capability_type' => 'post',
	'capabilities' => array(),
	'map_meta_cap' => false
);
print_r(get_post_type_capabilities((object) $args));

扩展阅读

get_post_type_capabilities()函数位于:wp-includes/post.php

相关函数:

  • register_post_type()

  • map_meta_cap()


欢迎咨询/Welcome to inquire
tel/vx:18842938855
qq:1685522781
email:1685522781@qq.com

Copyright © 2019-2024 wangzhan.shop


Whatsapp
Powered by RRZCMS