private function update_msuser_status( $user_ids, $pref, $value ) {

		// If site is not multisite, then stop execution.
		if ( ! is_multisite() ) {
			WP_CLI::error( 'This is not a multisite installation.' );
		}

		if ( 'spam' === $pref && '1' === $value ) {
			$action = (int) $value ? 'marked as spam' : 'removed from spam';
			$verb   = (int) $value ? 'spam' : 'unspam';
		}

		$successes = 0;
		$errors    = 0;
		$users     = $this->fetcher->get_many( $user_ids );
		if ( count( $users ) < count( $user_ids ) ) {
			$errors = count( $user_ids ) - count( $users );
		}

		foreach ( $user_ids as $user_id ) {

			$user = get_userdata( $user_id );

			// If no user found, then show warning.
			if ( empty( $user ) ) {
				WP_CLI::warning( "User {$user_id} doesn't exist." );
				continue;
			}

			// Super admin should not be marked as spam.
			if ( is_super_admin( $user->ID ) ) {
				WP_CLI::warning( "User cannot be modified. The user {$user->ID} is a network administrator." );
				continue;
			}

			// Skip if user is already marked as spam and show warning.
			if ( $value === $user->spam ) {
				WP_CLI::warning( "User {$user_id} already {$action}." );
				continue;
			}

			// Make that user's blog as spam too.
			$blogs = get_blogs_of_user( $user_id, true );
			foreach ( (array) $blogs as $details ) {
				$site = $this->sitefetcher->get_check( $details->site_id );

				// Main blog shouldn't a spam !
				if ( $details->userblog_id !== $site->blog_id ) {
					update_blog_status( $details->userblog_id, $pref, $value );
				}
			}

			// Set status and show message.
			update_user_status( $user_id, $pref, $value );
			WP_CLI::log( "User {$user_id} {$action}." );
			$successes++;
		}

		Utils\report_batch_operation_results( 'user', $verb, count( $user_ids ), $successes, $errors );
	}
private function update_msuser_status( $user_ids, $pref, $value ) {

		// If site is not multisite, then stop execution.
		if ( ! is_multisite() ) {
			WP_CLI::error( 'This is not a multisite installation.' );
		}

		if ( 'spam' === $pref && '1' === $value ) {
			$action = (int) $value ? 'marked as spam' : 'removed from spam';
			$verb   = (int) $value ? 'spam' : 'unspam';
		}

		$successes = 0;
		$errors    = 0;
		$users     = $this->fetcher->get_many( $user_ids );
		if ( count( $users ) < count( $user_ids ) ) {
			$errors = count( $user_ids ) - count( $users );
		}

		foreach ( $user_ids as $user_id ) {

			$user = get_userdata( $user_id );

			// If no user found, then show warning.
			if ( empty( $user ) ) {
				WP_CLI::warning( "User {$user_id} doesn't exist." );
				continue;
			}

			// Super admin should not be marked as spam.
			if ( is_super_admin( $user->ID ) ) {
				WP_CLI::warning( "User cannot be modified. The user {$user->ID} is a network administrator." );
				continue;
			}

			// Skip if user is already marked as spam and show warning.
			if ( $value === $user->spam ) {
				WP_CLI::warning( "User {$user_id} already {$action}." );
				continue;
			}

			// Make that user's blog as spam too.
			$blogs = get_blogs_of_user( $user_id, true );
			foreach ( (array) $blogs as $details ) {
				$site = $this->sitefetcher->get_check( $details->site_id );

				// Main blog shouldn't a spam !
				if ( $details->userblog_id !== $site->blog_id ) {
					update_blog_status( $details->userblog_id, $pref, $value );
				}
			}

			// Set status and show message.
			update_user_status( $user_id, $pref, $value );
			WP_CLI::log( "User {$user_id} {$action}." );
			$successes++;
		}

		Utils\report_batch_operation_results( 'user', $verb, count( $user_ids ), $successes, $errors );
	}
private function update_msuser_status ( $ user_ids , $ pref , $ value ) { // If site is not multisite, then stop execution. if ( ! is_multisite ( ) ) { WP_CLI :: error ( 'This is not a multisite installation.' ) ; } if ( 'spam' === $ pref && '1' === $ value ) { $ action = ( int ) $ value ? 'marked as spam' : 'removed from spam' ; $ verb = ( int ) $ value ? 'spam' : 'unspam' ; } $ successes = 0 ; $ errors = 0 ; $ users = $ this -> fetcher -> get_many ( $ user_ids ) ; if ( count ( $ users ) < count ( $ user_ids ) ) { $ errors = count ( $ user_ids ) - count ( $ users ) ; } foreach ( $ user_ids as $ user_id ) { $ user = get_userdata ( $ user_id ) ; // If no user found, then show warning. if ( empty ( $ user ) ) { WP_CLI :: warning ( "User {$user_id} doesn't exist." ) ; continue ; } // Super admin should not be marked as spam. if ( is_super_admin ( $ user -> ID ) ) { WP_CLI :: warning ( "User cannot be modified. The user {$user->ID} is a network administrator." ) ; continue ; } // Skip if user is already marked as spam and show warning. if ( $ value === $ user -> spam ) { WP_CLI :: warning ( "User {$user_id} already {$action}." ) ; continue ; } // Make that user's blog as spam too. $ blogs = get_blogs_of_user ( $ user_id , true ) ; foreach ( ( array ) $ blogs as $ details ) { $ site = $ this -> sitefetcher -> get_check ( $ details -> site_id ) ; // Main blog shouldn't a spam ! if ( $ details -> userblog_id !== $ site -> blog_id ) { update_blog_status ( $ details -> userblog_id , $ pref , $ value ) ; } } // Set status and show message. update_user_status ( $ user_id , $ pref , $ value ) ; WP_CLI :: log ( "User {$user_id} {$action}." ) ; $ successes ++ ; } Utils \ report_batch_operation_results ( 'user' , $ verb , count ( $ user_ids ) , $ successes , $ errors ) ; }
Common command for updating user data.
Common command for updating user data .