1. 首页
  2. WordPress 函数手册

author_can()

author_can( int|WP_Post $post, string $capability, mixed $args )

返回所提供文章的作者是否具有指定的功能。
Returns whether the author of the supplied post has the specified capability.

目录锚点:#说明#参数#返回#源码#笔记


说明(Description)

此函数还接受一个对象的ID,以检查该功能是否为元功能。元功能(如edit_post和edit_user)是map_Meta_cap()函数用来映射到用户或角色具有的基本功能(如edit_posts和edit_others_posts)的功能。

示例用法:

作者可以($post,’edit_posts’);

作者可以($post,’edit_post’,$post->ID);

作者可以($post,’edit_post_meta’,$post->ID,$meta_key);


参数(Parameters)

参数 类型 必填 说明
$post (int | WP_Post) 必需 Post ID或Post对象。
$capability (string) 必需 能力名称。
$args (mixed) 可选 其他参数,通常以对象ID开头。

返回(Return)

(bool)文章作者是否具有给定的能力。


源码(Source)


更新版本 源码位置 使用 被使用
5.3.0 wp-includes/capabilities.php:734 0 2

笔记(Notes)

例子

author_can() 为WP2原创文章,链接:https://www.wp2.cn/functions/author_can/