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

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


Description Description


Parameters Parameters

$post

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

$capability

(string) (Required) Capability name.


Top ↑

Return Return

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


Top ↑

Source 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 );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.9.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.