Changeset 12913
- Timestamp:
- 04/28/2021 11:49:31 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/classes/class-bp-email.php
r12353 r12913 1000 1000 } 1001 1001 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 1002 1010 /** 1003 1011 * Filters whether the email passes basic validation checks. -
trunk/tests/phpunit/testcases/core/optouts.php
r12903 r12913 182 182 } 183 183 184 public function test_bp_optout_prevents_bp_email_send() { 185 $old_current_user = get_current_user_id(); 186 187 $u1 = $this->factory->user->create(); 188 $this->set_current_user( $u1 ); 189 // Create an opt-out. 190 $args = array( 191 'email_address' => 'test2@example.com', 192 'user_id' => $u1, 193 'email_type' => 'annoyance' 194 ); 195 $i1 = bp_add_optout( $args ); 196 $email = new BP_Email( 'activity-at-message' ); 197 $email->set_from( 'test1@example.com' )->set_to( 'test2@example.com' )->set_subject( 'testing' ); 198 $email->set_content_html( 'testing' )->set_tokens( array( 'poster.name' => 'example' ) ); 199 200 $this->assertTrue( is_wp_error( $email->validate() ) ); 201 $this->set_current_user( $old_current_user ); 202 } 203 184 204 }
Note: See TracChangeset
for help on using the changeset viewer.