^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 8年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云2核2g仅需86元/年

wordpress函数grant_super_admin()用法示例

grant_super_admin( int $user_id )

Grants Super Admin privileges.


描述


参数

$user_id

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

新用户2核2g仅需86元/年    领取1153套模板    免费cdn流量包    ¥3188礼包


返回值

(bool) True on success, false on failure. This can fail when the user is already a super admin or when the $super_admins global is defined.


源代码

File: wp-includes/capabilities.php

function grant_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 is granted Super Admin privileges.
	 *
	 * @since 3.0.0
	 *
	 * @param int $user_id ID of the user that is about to be granted Super Admin privileges.
	 */
	do_action( 'grant_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 && ! in_array( $user->user_login, $super_admins ) ) {
		$super_admins[] = $user->user_login;
		update_site_option( 'site_admins' , $super_admins );

		/**
		 * Fires after the user is granted Super Admin privileges.
		 *
		 * @since 3.0.0
		 *
		 * @param int $user_id ID of the user that was granted Super Admin privileges.
		 */
		do_action( 'granted_super_admin', $user_id );
		return true;
	}
	return false;
}

更新日志

Version 描述
3.0.0 Introduced.

相关函数

Uses

  • wp-includes/capabilities.php:
    grant_super_admin
  • wp-includes/capabilities.php:
    granted_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


让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈