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/privacy/wpPrivacySendErasureFulfillmentNotification.php

    r46586 r47279  
    258258
    259259    /**
     260     * The email headers of the fulfillment notification should be filterable.
     261     *
     262     * @since 5.4.0
     263     *
     264     * @ticket 44501
     265     */
     266    public function test_email_headers_should_be_filterable() {
     267        add_filter( 'user_erasure_complete_email_headers', array( $this, 'modify_email_headers' ) );
     268        _wp_privacy_send_erasure_fulfillment_notification( self::$request_id );
     269
     270        $mailer = tests_retrieve_phpmailer_instance();
     271
     272        $this->assertContains( 'From: Tester <tester@example.com>', $mailer->get_sent()->header );
     273    }
     274
     275    /**
     276     * Filter callback that modifies the email headers of the data erasure fulfillment notification.
     277     *
     278     * @since 5.4.0
     279     *
     280     * @param string|array $headers The email headers.
     281     * @return array       $headers The new email headers.
     282     */
     283    public function modify_email_headers( $headers ) {
     284        $headers = array(
     285            'From: Tester <tester@example.com>',
     286        );
     287
     288        return $headers;
     289    }
     290
     291    /**
    260292     * The function should not send an email when the request ID does not exist.
    261293     *
Note: See TracChangeset for help on using the changeset viewer.