Ticket #44676: 44676.diff
File 44676.diff, 5.1 KB (added by , 7 years ago) |
---|
-
src/wp-admin/includes/user.php
684 684 'error' 685 685 ); 686 686 } 687 $action_type = sanitize_text_field( wp_unslash( $_POST['type_of_action'] ) );688 $username_or_email_address = sanitize_text_field( wp_unslash( $_POST['username_or_email_for_privacy_request'] ) );689 $email_address = '';690 687 688 $count = 0; 689 $failure_count = 0; 690 691 $action_type = sanitize_text_field( wp_unslash( $_POST['type_of_action'] ) ); 692 691 693 if ( ! in_array( $action_type, _wp_privacy_action_request_types(), true ) ) { 692 694 add_settings_error( 693 695 'action_type', … … 697 699 ); 698 700 } 699 701 700 if ( ! is_email( $username_or_email_address ) ) { 701 $user = get_user_by( 'login', $username_or_email_address ); 702 if ( ! $user instanceof WP_User ) { 703 add_settings_error( 704 'username_or_email_for_privacy_request', 705 'username_or_email_for_privacy_request', 706 __( 'Unable to add this request. A valid email address or username must be supplied.' ), 707 'error' 708 ); 702 $username_or_email_for_privacy_request = sanitize_text_field( wp_unslash( $_POST['username_or_email_for_privacy_request'] ) ); 703 $usernames_or_email_addresses = explode( ',', $username_or_email_for_privacy_request ); 704 705 foreach ( $usernames_or_email_addresses as $username_or_email_address ) { 706 $email_address = ''; 707 708 if ( ! is_email( $username_or_email_address ) ) { 709 $user = get_user_by( 'login', $username_or_email_address ); 710 if ( ! $user instanceof WP_User ) { 711 $failure_count++; 712 break; 713 } else { 714 $email_address = $user->user_email; 715 } 709 716 } else { 710 $email_address = $user ->user_email;717 $email_address = $username_or_email_address; 711 718 } 712 } else {713 $email_address = $username_or_email_address;714 }715 719 716 if ( empty( $email_address ) ) { 720 if ( empty( $email_address ) ) { 721 $failure_count++; 722 break; 723 } 724 725 $request_id = wp_create_user_request( $email_address, $action_type ); 726 727 if ( ! $request_id || is_wp_error( $request_id ) ) { 728 $failure_count++; 729 break; 730 } 731 732 $result = wp_send_user_request( $request_id ); 733 734 if ( ! $result || is_wp_error( $result ) ) { 735 $failure_count++; 736 break; 737 } 738 739 $count++; 717 740 break; 718 741 } 719 742 720 $request_id = wp_create_user_request( $email_address, $action_type ); 721 722 if ( is_wp_error( $request_id ) ) { 743 if ( $count ) { 723 744 add_settings_error( 724 745 'username_or_email_for_privacy_request', 725 746 'username_or_email_for_privacy_request', 726 $request_id->get_error_message(), 727 'error' 747 /* translators: %d: number of requests */ 748 sprintf( _n( '%d confirmation request initiated successfully.', '%d confirmation requests initiated successfully.', $count ), $count ), 749 'updated' 728 750 ); 729 break; 730 } elseif ( ! $request_id ) { 751 } 752 753 if ( $failure_count ) { 731 754 add_settings_error( 732 755 'username_or_email_for_privacy_request', 733 756 'username_or_email_for_privacy_request', 734 __( 'Unable to initiate confirmation request.' ), 735 'error' 757 /* translators: %d: number of requests */ 758 sprintf( _n( 'Unable to initiate %d confirmation request.', 'Unable to initiate %d confirmation requests.', $count ), $count ), 759 'updated' 736 760 ); 737 break;738 761 } 739 740 wp_send_user_request( $request_id );741 742 add_settings_error(743 'username_or_email_for_privacy_request',744 'username_or_email_for_privacy_request',745 __( 'Confirmation request initiated successfully.' ),746 'updated'747 );748 762 break; 749 763 } 750 764 } … … 822 836 823 837 <form method="post" class="wp-privacy-request-form"> 824 838 <h2><?php esc_html_e( 'Add Data Export Request' ); ?></h2> 825 <p><?php esc_html_e( 'An email will be sent to the user at this email address asking them to verify the request.' ); ?></p> 839 <p><?php esc_html_e( 'An email will be sent to the user asking them to verify the request.' ); ?></p> 840 <p><?php esc_html_e( 'To trigger multiple requests supply the usernames or email addresses in a comma deliminated list.' ); ?></p> 826 841 827 842 <div class="wp-privacy-request-form-field"> 828 843 <label for="username_or_email_for_privacy_request"><?php esc_html_e( 'Username or email address' ); ?></label> … … 897 912 898 913 <form method="post" class="wp-privacy-request-form"> 899 914 <h2><?php esc_html_e( 'Add Data Erasure Request' ); ?></h2> 900 <p><?php esc_html_e( 'An email will be sent to the user at this email address asking them to verify the request.' ); ?></p> 915 <p><?php esc_html_e( 'An email will be sent to the user asking them to verify the request.' ); ?></p> 916 <p><?php esc_html_e( 'To trigger multiple requests supply the usernames or email addresses in a comma deliminated list.' ); ?></p> 901 917 902 918 <div class="wp-privacy-request-form-field"> 903 919 <label for="username_or_email_for_privacy_request"><?php esc_html_e( 'Username or email address' ); ?></label>