函数原型
current_user_can( string $capability, mixed $args ): bool
函数描述
Returns whether the current user has the specified capability.
是否弃用
未弃用
函数参数
-
$capability
string
Required - Capability name.
-
$args
mixed
Optional - further parameters, typically starting with an object ID.
函数返回值
bool Whether the current user has the given capability. If $capability is a meta cap and $object_id is passed, whether the current user has the given meta capability for the given object.
函数位置
File: wp-includes/capabilities.php.
函数源码
current_user_can( 'edit_posts' );
current_user_can( 'edit_post', $post->ID );
current_user_can( 'edit_post_meta', $post->ID, $meta_key );源码链接
变更日志
| Version | Description |
|---|---|
| 5.8.0 | Converted to wrapper for the user_can() function. |
| 5.3.0 | Formalized the existing and already documented ...$args parameter by adding it to the function signature. |
| 2.0.0 | Introduced. |

