函数原型
author_can( int|WP_Post $post, string $capability, mixed $args ): bool
函数描述
Returns whether the author of the supplied post has the specified capability.
是否弃用
未弃用
函数参数
-
$post
int|WP_Post
Required - Post ID or post object.
-
$capability
string
Required - Capability name.
-
$args
mixed
Optional - further parameters, typically starting with an object ID.
函数返回值
bool Whether the post author has the given capability.
函数位置
File: wp-includes/capabilities.php.
函数源码
author_can( $post, 'edit_posts' );
author_can( $post, 'edit_post', $post->ID );
author_can( $post, 'edit_post_meta', $post->ID, $meta_key );源码链接
变更日志
| Version | Description |
|---|---|
| 5.3.0 | Formalized the existing and already documented ...$args parameter by adding it to the function signature. |
| 2.9.0 | Introduced. |

