W3cubDocs

/WordPress

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

Whether the author of the supplied post has a specific capability.

Description

Parameters

$post

(int|WP_Post) (Required) Post ID or post object.

$capability

(string) (Required) Capability name.

Return

(bool) Whether the post author has the given capability.

Source

File: wp-includes/capabilities.php

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

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

	if ( ! $author ) {
		return false;
	}

	$args = array_slice( func_get_args(), 2 );
	$args = array_merge( array( $capability ), $args );

	return call_user_func_array( array( $author, 'has_cap' ), $args );
}

Changelog

Version Description
2.9.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/author_can