File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed
Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -422,3 +422,41 @@ Feature: Manage WordPress users
422422 Error: Only spammed 1 of 2 users.
423423 """
424424 And the return code should be 1
425+
426+ @require-wp-4.3
427+ Scenario : Sending emails on update
428+ Given a WP install
429+
430+ When I run `wp user get 1 --field=user_email`
431+ Then save STDOUT as {ORIGINAL_EMAIL}
432+
433+ When I run `wp user update 1 --user_email=different.mail@example.com`
434+ Then STDOUT should contain:
435+ """
436+ Success: Updated user 1.
437+ """
438+ And an email should be sent
439+
440+ When I run `wp user update 1 --user_email={ORIGINAL_EMAIL} --skip-email`
441+ Then STDOUT should contain:
442+ """
443+ Success: Updated user 1.
444+ """
445+ And an email should not be sent
446+
447+ When I run `wp user get 1 --field=user_pass`
448+ Then save STDOUT as {ORIGINAL_PASSWORD}
449+
450+ When I run `wp user update 1 --user_pass=different_password`
451+ Then STDOUT should contain:
452+ """
453+ Success: Updated user 1.
454+ """
455+ And an email should be sent
456+
457+ When I run `wp user update 1 --user_pass={ORIGINAL_PASSWORD} --skip-email`
458+ Then STDOUT should contain:
459+ """
460+ Success: Updated user 1.
461+ """
462+ And an email should not be sent
Original file line number Diff line number Diff line change @@ -478,6 +478,9 @@ public function create( $args, $assoc_args ) {
478478 * --<field>=<value>
479479 * : One or more fields to update. For accepted fields, see wp_update_user().
480480 *
481+ * [--skip-email]
482+ * : Don't send an email notification to the user.
483+ *
481484 * ## EXAMPLES
482485 *
483486 * # Update user
@@ -495,8 +498,19 @@ public function update( $args, $assoc_args ) {
495498 $ user_ids [] = $ user ->ID ;
496499 }
497500
501+ $ skip_email = Utils \get_flag_value ( $ assoc_args , 'skip-email ' );
502+ if ( $ skip_email ) {
503+ add_filter ( 'send_email_change_email ' , '__return_false ' );
504+ add_filter ( 'send_password_change_email ' , '__return_false ' );
505+ }
506+
498507 $ assoc_args = wp_slash ( $ assoc_args );
499508 parent ::_update ( $ user_ids , $ assoc_args , 'wp_update_user ' );
509+
510+ if ( $ skip_email ) {
511+ remove_filter ( 'send_email_change_email ' , '__return_false ' );
512+ remove_filter ( 'send_password_change_email ' , '__return_false ' );
513+ }
500514 }
501515
502516 /**
You can’t perform that action at this time.
0 commit comments