函数原型
current_user_can_for_blog( int $blog_id, string $capability, mixed $args ): bool
函数描述
Returns whether the current user has the specified capability for a given site.
是否弃用
未弃用
函数参数
-
$blog_id
int
Required - Site ID.
-
$capability
string
Required - Capability name.
-
$args
mixed
Optional - further parameters, typically starting with an object ID.
函数返回值
bool Whether the user has the given capability.
函数位置
File: wp-includes/capabilities.php.
函数源码
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 );源码链接
变更日志
| Version | Description |
|---|---|
| 5.8.0 | Wraps current_user_can() after switching to blog. |
| 5.3.0 | Formalized the existing and already documented ...$args parameter by adding it to the function signature. |
| 3.0.0 | Introduced. |

