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