src/Super_Admin_Command.php
public function add( $args, $_ ) {

		$successes = 0;
		$errors    = 0;
		$users     = $this->fetcher->get_many( $args );
		if ( count( $users ) !== count( $args ) ) {
			$errors = count( $args ) - count( $users );
		}
		$user_logins      = wp_list_pluck( $users, 'user_login' );
		$super_admins     = self::get_admins();
		$num_super_admins = count( $super_admins );

		foreach ( $user_logins as $user_login ) {
			if ( in_array( $user_login, $super_admins, true ) ) {
				WP_CLI::warning( "User '{$user_login}' already has super-admin capabilities." );
				continue;
			}

			$super_admins[] = $user_login;
			$successes++;
		}

		if ( count( $super_admins ) === $num_super_admins ) {
			if ( $errors ) {
				$user_count = count( $args );
				WP_CLI::error( "Couldn't grant super-admin capabilities to {$errors} of {$user_count} users." );
			} else {
				WP_CLI::success( 'Super admins remain unchanged.' );
			}
		} else {
			if ( update_site_option( 'site_admins', $super_admins ) ) {
				if ( $errors ) {
					$user_count = count( $args );
					WP_CLI::error( "Only granted super-admin capabilities to {$successes} of {$user_count} users." );
				} else {
					$message = $successes > 1 ? 'users' : 'user';
					WP_CLI::success( "Granted super-admin capabilities to {$successes} {$message}." );
				}
			} else {
				WP_CLI::error( 'Site options update failed.' );
			}
		}
	}
public function add( $args, $_ ) {

		$successes = 0;
		$errors    = 0;
		$users     = $this->fetcher->get_many( $args );
		if ( count( $users ) !== count( $args ) ) {
			$errors = count( $args ) - count( $users );
		}
		$user_logins      = wp_list_pluck( $users, 'user_login' );
		$super_admins     = self::get_admins();
		$num_super_admins = count( $super_admins );

		foreach ( $user_logins as $user_login ) {
			if ( in_array( $user_login, $super_admins, true ) ) {
				WP_CLI::warning( "User '{$user_login}' already has super-admin capabilities." );
				continue;
			}

			$super_admins[] = $user_login;
			$successes++;
		}

		if ( count( $super_admins ) === $num_super_admins ) {
			if ( $errors ) {
				$user_count = count( $args );
				WP_CLI::error( "Couldn't grant super-admin capabilities to {$errors} of {$user_count} users." );
			} else {
				WP_CLI::success( 'Super admins remain unchanged.' );
			}
		} else {
			if ( update_site_option( 'site_admins', $super_admins ) ) {
				if ( $errors ) {
					$user_count = count( $args );
					WP_CLI::error( "Only granted super-admin capabilities to {$successes} of {$user_count} users." );
				} else {
					$message = $successes > 1 ? 'users' : 'user';
					WP_CLI::success( "Granted super-admin capabilities to {$successes} {$message}." );
				}
			} else {
				WP_CLI::error( 'Site options update failed.' );
			}
		}
	}
public function add ( $ args , $ _ ) { $ successes = 0 ; $ errors = 0 ; $ users = $ this -> fetcher -> get_many ( $ args ) ; if ( count ( $ users ) !== count ( $ args ) ) { $ errors = count ( $ args ) - count ( $ users ) ; } $ user_logins = wp_list_pluck ( $ users , 'user_login' ) ; $ super_admins = self :: get_admins ( ) ; $ num_super_admins = count ( $ super_admins ) ; foreach ( $ user_logins as $ user_login ) { if ( in_array ( $ user_login , $ super_admins , true ) ) { WP_CLI :: warning ( "User '{$user_login}' already has super-admin capabilities." ) ; continue ; } $ super_admins [ ] = $ user_login ; $ successes ++ ; } if ( count ( $ super_admins ) === $ num_super_admins ) { if ( $ errors ) { $ user_count = count ( $ args ) ; WP_CLI :: error ( "Couldn't grant super-admin capabilities to {$errors} of {$user_count} users." ) ; } else { WP_CLI :: success ( 'Super admins remain unchanged.' ) ; } } else { if ( update_site_option ( 'site_admins' , $ super_admins ) ) { if ( $ errors ) { $ user_count = count ( $ args ) ; WP_CLI :: error ( "Only granted super-admin capabilities to {$successes} of {$user_count} users." ) ; } else { $ message = $ successes > 1 ? 'users' : 'user' ; WP_CLI :: success ( "Granted super-admin capabilities to {$successes} {$message}." ) ; } } else { WP_CLI :: error ( 'Site options update failed.' ) ; } } }
Grants super admin privileges to one or more users.

## OPTIONS

<user>...
: One or more user IDs, user emails, or user logins.

## EXAMPLES

$ wp super-admin add superadmin2
Success: Granted super-admin capabilities.
Grants super admin privileges to one or more users .