From 2d1f62196e66df9dbd267750c2fdbb2438681453 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Tue, 27 Feb 2024 16:21:25 +0545 Subject: [PATCH] Fix warning message in user spam command --- features/user.feature | 1 - src/User_Command.php | 11 ++--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/features/user.feature b/features/user.feature index 3302b105..a1970a93 100644 --- a/features/user.feature +++ b/features/user.feature @@ -586,7 +586,6 @@ Feature: Manage WordPress users And STDERR should be: """ Warning: Invalid user ID, email or login: '9999' - Warning: User 9999 doesn't exist. Error: Only spammed 1 of 2 users. """ And the return code should be 1 diff --git a/src/User_Command.php b/src/User_Command.php index 0ff3eda5..46bf1ec8 100644 --- a/src/User_Command.php +++ b/src/User_Command.php @@ -1339,15 +1339,8 @@ private function update_msuser_status( $user_ids, $pref, $value ) { $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; - } + foreach ( $users as $user ) { + $user_id = $user->ID; // Super admin should not be marked as spam. if ( is_super_admin( $user->ID ) ) {