当前浏览:首页 / WordPress函数 / current_user_can_for_blog()

current_user_can_for_blog( int $blog_id, string $capability, mixed $args )

返回当前用户是否具有给定站点的指定能力

blog

can

current

usermore...


描述

此函数还接受对象的ID,以检查该能力是否为meta能力。meta能力(如edit_postedit_user)是map_meta_cap()函数用来映射到用户或角色具有的基本能力(如,edit_postsedit_others_posts)的能力。

用法示例:

current_user_can_for_blog( $blog_id, 'edit_posts' );
current_user_can_for_blog( $blog_id, 'edit_post', $post->ID );
current_user_can_for_blog( $blog_id, 'edit_post_meta', $post->ID, $meta_key );

参数

$blog_id

(int)(必填) 站点ID。

$capability

(string)(必填) 能力名称。

$args

(mixed)(可选) 通常由对象ID开始的其他参数。


返回

(bool) 用户是否具有给定能力。



源码

查看源码 官方文档


更新日志

版本描述
5.8.0切换到博客后封装current_user_can()
5.3.0通过将...$args参数添加到函数签名中,将其形参化。
3.0.0开始引入