current_user_can_for_blog()

最后更新于:2021-11-25 22:49:05

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

响应s 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.

源文件

文件: gc-includes/capabilities.php

function current_user_can_for_blog( $blog_id, $capability, ...$args ) {
	$switched = is_multisite() ? switch_to_blog( $blog_id ) : false;

	$can = current_user_can( $capability, ...$args );

	if ( $switched ) {
		restore_current_blog();
	}

	return $can;
}