WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/author can

Description

Whether author of supplied post has capability or role.

Usage

 <?php author_can$post$capability ); ?> 

Parameters

$post
(mixed) (required) Post ID or post object
Default: None
$capability
(string) (required) Capability or role name.
Default: None

Returns

(boolean) 
whether author can or not.

Example

<?php
if (author_can($post->ID, 'publish_posts')) {
  echo "Yes he can publish posts!";
}
?>

Changelog

Since: Wordpress 2.9.0

Source Code

author_can() is located in wp-includes/capabilities.php.

Related

Roles and Capabilities

See also index of Function Reference and index of Template Tags.