Advertisements

grant_super_admin

Definition:
function grant_super_admin( $user_id ) {}

Grants super admin privileges.

Parameters

  • int $user_id

Defined actions

  • grant_super_admin
    do_action( 'grant_super_admin', $user_id );
  • granted_super_admin
    do_action( 'granted_super_admin', $user_id );

Source code

function grant_super_admin( $user_id ) {

	global $super_admins;



	// If global super_admins override is defined, there is nothing to do here.

	if ( isset($super_admins) )

		return false;



	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 = new WP_User( $user_id );

	if ( ! in_array( $user->user_login, $super_admins ) ) {

		$super_admins[] = $user->user_login;

		update_site_option( 'site_admins' , $super_admins );

		do_action( 'granted_super_admin', $user_id );

		return true;

	}

	return false;

}

1923

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: