user_can() - WordPress 函数参考中文文档

返回介绍

user_can()

发布于 2017-09-11 字数1708 浏览 956 评论 0

user_can( int|object $user,  string $capability )

Whether a particular user has capability or role.


描述


参数

$user

(int|object)
(Required)
User ID or object.

$capability

(string)
(Required)
Capability or role name.


返回值

(bool)


源代码

File: wp-includes/capabilities.php

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 );
}

更新日志

Version 描述
3.1.0 Introduced.

相关函数

Uses

  • wp-includes/pluggable.php:
    get_userdata()

Used By

  • wp-includes/capabilities.php:
    map_meta_cap()
  • wp-includes/pluggable.php:
    wp_notify_postauthor()
  • wp-includes/pluggable.php:
    wp_notify_moderator()
  • wp-includes/functions.php:
    get_allowed_mime_types()
  • wp-includes/link-template.php:
    get_dashboard_url()

User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!