WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/11/2020 09:41:26 PM (21 months ago)
Author:
SergeyBiryukov
Message:

Privacy: Introduce filters for the headers of all the privacy-related e-mails:

  • wp_privacy_personal_data_email_headers
  • user_request_confirmed_email_headers
  • user_erasure_complete_email_headers
  • user_request_action_email_headers

Props xkon, garrett-eclipse, zaffarn, desrosj.
Fixes #44501.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/user/wpSendUserRequest.php

    r46586 r47279  
    230230
    231231    /**
     232     * The email headers should be filterable.
     233     *
     234     * @since 5.4.0
     235     *
     236     * @ticket 44501
     237     */
     238    public function test_email_headers_should_be_filterable() {
     239        $request_id = wp_create_user_request( self::$test_user->user_email, 'remove_personal_data' );
     240
     241        add_filter( 'user_request_action_email_headers', array( $this, 'modify_email_headers' ) );
     242        $result = wp_send_user_request( $request_id );
     243
     244        $mailer = tests_retrieve_phpmailer_instance();
     245
     246        $this->assertContains( 'From: Tester <tester@example.com>', $mailer->get_sent()->header );
     247    }
     248
     249    /**
     250     * Filter callback to modify the headers of the email sent when an account action is attempted.
     251     *
     252     * @since 5.4.0
     253     *
     254     * @param string|array $headers The email headers.
     255     * @return array       $headers The new email headers.
     256     */
     257    public function modify_email_headers( $headers ) {
     258        $headers = array(
     259            'From: Tester <tester@example.com>',
     260        );
     261
     262        return $headers;
     263    }
     264
     265    /**
    232266     * The function should error when the email was not sent.
    233267     *
Note: See TracChangeset for help on using the changeset viewer.