WordPress开发者和主题制作者的搜索引擎



user_can ›

Since3.1.0
已弃用n/a
user_can ( $user, $capability )
参数: (2)
  • (int|WP_User) $user User ID or object.
    Required: Yes
  • (string) $capability Capability name.
    Required: Yes
返回:
  • (bool) Whether the user has the given capability.
定义在:
文档:

Whether a particular user has a specific capability.



源码

function user_can( $user, $capability ) {
	if ( ! is_object( $user ) ) {
		$user = get_userdata( $user );
	}

	if ( ! $user || ! $user->exists() ) {
		return false;
	}

	$args = array_slice( func_get_args(), 2 );
	$args = array_merge( array( $capability ), $args );

	return call_user_func_array( array( $user, 'has_cap' ), $args );
}