Changeset 13894
- Timestamp:
- 06/02/2024 06:35:51 AM (14 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-members/bp-members-functions.php
r13890 r13894 647 647 * @since 5.0.0 648 648 * 649 * @param int $user_id The user ID to spam or ham.650 * @param int $value 0 to mark the user as `ham`, 1to mark as `spam`.649 * @param int $user_id The user ID to spam or ham. 650 * @param string $value '0' to mark the user as `ham`, '1' to mark as `spam`. 651 651 * @return bool True if the spam status of the member changed. 652 652 * False otherwise. … … 665 665 } 666 666 667 if ( $value ) { 668 $value = '1'; 669 } 670 667 671 // Otherwise use the replacement function. 668 $user = wp_update_user( array( 669 'ID' => $user_id, 670 'spam' => $value, 671 ) ); 672 $user = wp_update_user( 673 array( 674 'ID' => $user_id, 675 'spam' => $value, 676 ) 677 ); 672 678 673 679 if ( is_wp_error( $user ) ) { -
trunk/tests/phpunit/testcases/members/functions.php
r13433 r13894 6 6 class BP_Tests_Members_Functions extends BP_UnitTestCase { 7 7 protected $permalink_structure = ''; 8 protected $filter_fired = ''; 8 9 9 10 public function set_up() { … … 507 508 } 508 509 510 public function notification_filter_callback() { 511 $this->filter_fired = current_action(); 512 } 513 509 514 /** 510 515 * @group bp_core_process_spammer_status 511 516 */ 512 517 public function test_bp_core_process_spammer_status_make_spam_user_filter() { 513 add_filter( 'make_spam_user', array( $this, 'notification_filter_callback' ) ); 514 515 $u1 = self::factory()->user->create(); 518 $u1 = self::factory()->user->create(); 519 520 add_action( 'make_spam_user', array( $this, 'notification_filter_callback' ) ); 521 516 522 $n = bp_core_process_spammer_status( $u1, 'spam' ); 517 523 518 remove_ filter( 'make_spam_user', array( $this, 'notification_filter_callback' ) );524 remove_action( 'make_spam_user', array( $this, 'notification_filter_callback' ) ); 519 525 520 526 $this->assertSame( 'make_spam_user', $this->filter_fired ); 521 522 527 } 523 528 … … 526 531 $s = bp_core_process_spammer_status( $u1, 'spam' ); 527 532 528 add_ filter( 'make_ham_user', array( $this, 'notification_filter_callback' ) );533 add_action( 'make_ham_user', array( $this, 'notification_filter_callback' ) ); 529 534 530 535 $h = bp_core_process_spammer_status( $u1, 'ham' ); 531 536 532 remove_ filter( 'make_ham_user', array( $this, 'notification_filter_callback' ) );537 remove_action( 'make_ham_user', array( $this, 'notification_filter_callback' ) ); 533 538 534 539 $this->assertSame( 'make_ham_user', $this->filter_fired ); … … 537 542 538 543 public function test_bp_core_process_spammer_status_bp_make_spam_user_filter() { 539 add_ filter( 'bp_make_spam_user', array( $this, 'notification_filter_callback' ) );544 add_action( 'bp_make_spam_user', array( $this, 'notification_filter_callback' ) ); 540 545 541 546 $u1 = self::factory()->user->create(); 542 547 $n = bp_core_process_spammer_status( $u1, 'spam' ); 543 548 544 remove_ filter( 'bp_make_spam_user', array( $this, 'notification_filter_callback' ) );549 remove_action( 'bp_make_spam_user', array( $this, 'notification_filter_callback' ) ); 545 550 546 551 $this->assertSame( 'bp_make_spam_user', $this->filter_fired ); … … 549 554 550 555 public function test_bp_core_process_spammer_status_bp_make_ham_user_filter() { 551 add_ filter( 'bp_make_ham_user', array( $this, 'notification_filter_callback' ) );556 add_action( 'bp_make_ham_user', array( $this, 'notification_filter_callback' ) ); 552 557 553 558 $u1 = self::factory()->user->create(); 554 559 $n = bp_core_process_spammer_status( $u1, 'ham' ); 555 560 556 remove_ filter( 'bp_make_ham_user', array( $this, 'notification_filter_callback' ) );561 remove_action( 'bp_make_ham_user', array( $this, 'notification_filter_callback' ) ); 557 562 558 563 $this->assertSame( 'bp_make_ham_user', $this->filter_fired ); … … 583 588 $site = get_site( $b1 ); 584 589 $this->assertEmpty( $site->spam ); 585 }586 587 public function notification_filter_callback( $value ) {588 $this->filter_fired = current_filter();589 return $value;590 590 } 591 591
Note: See TracChangeset
for help on using the changeset viewer.