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

返回介绍

is_site_admin()

发布于 2017-09-11 字数1853 浏览 902 评论 0

Warning: This function has been deprecated. Use is_super_admin() instead.

is_site_admin( string $user_login = '' )

Determine if user is a site admin.


描述

Plugins should use is_multisite() instead of checking if this function exists to determine if multisite is enabled.

This function must reside in a file included only if is_multisite() due to legacy function_exists() checks to determine if multisite is enabled.


参数

$user_login

(string)
(Optional)
Username for the user to check.

Default value: ”


源代码

File: wp-includes/ms-deprecated.php

function is_site_admin( $user_login = '' ) {
	_deprecated_function( __FUNCTION__, '3.0.0', 'is_super_admin()' );

	if ( empty( $user_login ) ) {
		$user_id = get_current_user_id();
		if ( !$user_id )
			return false;
	} else {
		$user = get_user_by( 'login', $user_login );
		if ( ! $user->exists() )
			return false;
		$user_id = $user->ID;
	}

	return is_super_admin( $user_id );
}

更新日志

Version 描述
3.0.0 Use is_super_admin()
MU Introduced.

相关函数

Uses

  • wp-includes/capabilities.php:
    is_super_admin()
  • wp-includes/pluggable.php:
    get_user_by()
  • wp-includes/functions.php:
    _deprecated_function()
  • wp-includes/user.php:
    get_current_user_id()

User Contributed Notes

上一篇:is_singular()

下一篇:is_ssl()

发布评论

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

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