返回介绍

revoke_super_admin()

发布于 2017-09-11 10:17:10 字数 2585 浏览 1069 评论 0 收藏 0

revoke_super_admin( int $user_id )

Revokes Super Admin privileges.


description


参数

$user_id

(int) (Required) ID of the user Super Admin privileges to be revoked from.


返回值

(bool) True on success, false on failure. This can fail when the user's email is the network admin email or when the $super_admins global is defined.


源代码

File: wp-includes/capabilities.php

function revoke_super_admin( $user_id ) {
	// If global super_admins override is defined, there is nothing to do here.
	if ( isset( $GLOBALS['super_admins'] ) || ! is_multisite() ) {
		return false;
	}

	/**
	 * Fires before the user's Super Admin privileges are revoked.
	 *
	 * @since 3.0.0
	 *
	 * @param int $user_id ID of the user Super Admin privileges are being revoked from.
	 */
	do_action( 'revoke_super_admin', $user_id );

	// Directly fetch site_admins instead of using get_super_admins()
	$super_admins = get_site_option( 'site_admins', array( 'admin' ) );

	$user = get_userdata( $user_id );
	if ( $user && 0 !== strcasecmp( $user->user_email, get_site_option( 'admin_email' ) ) ) {
		if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) {
			unset( $super_admins[$key] );
			update_site_option( 'site_admins', $super_admins );

			/**
			 * Fires after the user's Super Admin privileges are revoked.
			 *
			 * @since 3.0.0
			 *
			 * @param int $user_id ID of the user Super Admin privileges were revoked from.
			 */
			do_action( 'revoked_super_admin', $user_id );
			return true;
		}
	}
	return false;
}

更新日志

Versiondescription
3.0.0Introduced.

相关函数

Uses

  • wp-includes/capabilities.php: revoke_super_admin
  • wp-includes/capabilities.php: revoked_super_admin
  • wp-includes/pluggable.php: get_userdata()
  • wp-includes/load.php: is_multisite()
  • wp-includes/plugin.php: do_action()
  • wp-includes/option.php: update_site_option()
  • wp-includes/option.php: get_site_option()
  • Show 2 more uses Hide more uses

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文