author_can( int|object $post, string $capability )
Whether author of supplied post has capability or role.
描述
参数
- $post
-
(int|object)
(Required)
Post ID or post object. - $capability
-
(string)
(Required)
Capability or role name.
返回值
(bool)
源代码
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 );
}
更新日志
Version | 描述 |
---|---|
2.9.0 | Introduced. |
相关函数
Uses
-
wp-includes/pluggable.php:
get_userdata() -
wp-includes/post.php:
get_post()
User Contributed Notes
-
Skip to note content
You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note
Contributed by
Codex
Example
if ( author_can( $post->ID, 'publish_posts' ) ) { echo __( 'Yes they can publish posts!', 'textdomain' ); }
你可能对这些文章感兴趣:
- wordpress函数get_all_post_type_supports()用法示例
- wordpress函数get_all_user_settings()用法示例
- wordpress函数get_all_category_ids()用法示例
- wordpress函数get_all_page_ids()用法示例
- wordpress函数get_allowed_themes()用法示例
- wordpress函数get_allowed_mime_types()用法示例
- wordpress函数get_alloptions_110()用法示例
- wordpress函数get_allowed_http_origins()用法示例
- wordpress函数get_alloptions()用法示例
- wordpress函数get_admin_users_for_domain()用法示例
- wordpress函数get_admin_page_title()用法示例
- wordpress函数get_admin_url()用法示例
- wordpress函数get_adjacent_post_rel_link()用法示例
- wordpress函数get_admin_page_parent()用法示例
如有疑问,请前往问答中心反馈!
反馈