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

返回介绍

revoke_super_admin()

发布于 2017-09-11 字数2587 浏览 994 评论 0

revoke_super_admin( int $user_id )

Revokes Super Admin privileges.


描述


参数

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

更新日志

Version 描述
3.0.0 Introduced.

相关函数

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

上一篇:retrieve_widgets()

下一篇:rewind_posts()

发布评论

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

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