File tree Expand file tree Collapse file tree 2 files changed +40
-2
lines changed
Expand file tree Collapse file tree 2 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -267,6 +267,43 @@ Feature: Manage WordPress users
267267 Bob Jones
268268 """
269269
270+ # The error message changed in WP 5.9.
271+ @less-than-wp-5.9
272+ Scenario: Creating a user with an existing email in multisite shows a clean error message
273+ Given a WP multisite install
274+
275+ When I run `wp user create bobjones bobjones@example.com`
276+ Then STDOUT should not be empty
277+
278+ When I try `wp user create bobjones2 bobjones@example.com`
279+ Then STDERR should contain:
280+ """
281+ Sorry, that email address is already used!
282+ """
283+ And STDERR should not contain:
284+ """
285+ <
286+ """
287+ And the return code should be 1
288+
289+ @require-wp-5.9
290+ Scenario: Creating a user with an existing email in multisite shows a clean error message
291+ Given a WP multisite install
292+
293+ When I run `wp user create bobjones bobjones@example.com`
294+ Then STDOUT should not be empty
295+
296+ When I try `wp user create bobjones2 bobjones@example.com`
297+ Then STDERR should contain:
298+ """
299+ This email address is already registered.
300+ """
301+ And STDERR should not contain:
302+ """
303+ <
304+ """
305+ And the return code should be 1
306+
270307 Scenario: Managing user roles
271308 Given a WP install
272309
Original file line number Diff line number Diff line change @@ -460,7 +460,8 @@ public function create( $args, $assoc_args ) {
460460 if ( is_multisite () ) {
461461 $ result = wpmu_validate_user_signup ( $ user ->user_login , $ user ->user_email );
462462 if ( ! empty ( $ result ['errors ' ]->errors ) ) {
463- WP_CLI ::error ( $ result ['errors ' ] );
463+ $ error_message = implode ( ' ' , array_map ( 'wp_strip_all_tags ' , $ result ['errors ' ]->get_error_messages () ) );
464+ WP_CLI ::error ( $ error_message );
464465 }
465466 $ user_id = wpmu_create_user ( $ user ->user_login , $ user ->user_pass , $ user ->user_email );
466467 if ( ! $ user_id ) {
@@ -1228,7 +1229,7 @@ public function import_csv( $args, $assoc_args ) {
12281229 if ( is_multisite () ) {
12291230 $ result = wpmu_validate_user_signup ( $ new_user ['user_login ' ], $ new_user ['user_email ' ] );
12301231 if ( ! empty ( $ result ['errors ' ]->errors ) ) {
1231- WP_CLI ::warning ( $ result ['errors ' ] );
1232+ WP_CLI ::warning ( implode ( ' ' , array_map ( ' wp_strip_all_tags ' , $ result ['errors ' ]-> get_error_messages () ) ) );
12321233 continue ;
12331234 }
12341235 $ user_id = wpmu_create_user ( $ new_user ['user_login ' ], $ new_user ['user_pass ' ], $ new_user ['user_email ' ] );
You can’t perform that action at this time.
0 commit comments