Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/28/2021 11:49:31 PM (5 months ago)
Author:
dcavins
Message:

BP_Optout: Prevent bp_send_email() delivery to opted-out address.

In BP_Email::validate() ensure that the recipient has
not opted out from communications from this site.

See #8448.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-email.php

    r12353 r12913  
    10001000        }
    10011001
     1002        // Has the user opted out of receiving any email from this site?
     1003        $recipient_to       = $this->get_to();
     1004        $recipient_to_first = array_shift( $recipient_to );
     1005        $recipient_address  = $recipient_to_first->get_address();
     1006        if ( bp_user_has_opted_out( $recipient_address ) ) {
     1007            $retval = new WP_Error( 'user_has_opted_out', __( 'The email recipient has opted out from receiving communication from this site.', 'buddypress' ), $recipient_address );
     1008        }
     1009
    10021010        /**
    10031011         * Filters whether the email passes basic validation checks.
Note: See TracChangeset for help on using the changeset viewer.