author_can()

最后更新于:2021-11-25 19:51:49

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

响应s whether the author of the supplied post has the specified capability.

参数

$post

(int|GC_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.

源文件

文件: gc-includes/capabilities.php

function author_can( $post, $capability, ...$args ) {
	$post = get_post( $post );
	if ( ! $post ) {
		return false;
	}

	$author = get_userdata( $post->post_author );

	if ( ! $author ) {
		return false;
	}

	return $author->has_cap( $capability, ...$args );
}