diff --git src/bp-members/bp-members-functions.php src/bp-members/bp-members-functions.php
index 58fd1777e..5af62bda2 100644
|
|
function bp_core_get_active_member_count() { |
609 | 609 | return apply_filters( 'bp_core_get_active_member_count', $count ); |
610 | 610 | } |
611 | 611 | |
| 612 | /** |
| 613 | * Update the spam status of the member on multisite configs. |
| 614 | * |
| 615 | * @since 5.0.0 |
| 616 | * |
| 617 | * @param int $user_id The user ID to spam or ham. |
| 618 | * @param int $value 0 to mark the user as `ham`, 1 to mark as `spam`. |
| 619 | * @return bool True if the spam status of the member changed. |
| 620 | * False otherwise. |
| 621 | */ |
| 622 | function bp_core_update_member_status( $user_id = 0, $value = 0 ) { |
| 623 | if ( ! is_multisite() || ! $user_id ) { |
| 624 | return false; |
| 625 | } |
| 626 | |
| 627 | if ( ! function_exists( 'wp_get_registered_image_subsizes' ) ) { |
| 628 | return update_user_status( $user_id, 'spam', $value ); |
| 629 | } |
| 630 | |
| 631 | $user = wp_update_user( array( |
| 632 | 'ID' => $user_id, |
| 633 | 'spam' => $value, |
| 634 | ) ); |
| 635 | |
| 636 | if ( is_wp_error( $user ) ) { |
| 637 | return false; |
| 638 | } |
| 639 | |
| 640 | return true; |
| 641 | } |
| 642 | |
612 | 643 | /** |
613 | 644 | * Process a spammed or unspammed user. |
614 | 645 | * |
… |
… |
function bp_core_process_spammer_status( $user_id, $status, $do_wp_cleanup = tru |
671 | 702 | } |
672 | 703 | |
673 | 704 | // Finally, mark this user as a spammer. |
674 | | if ( is_multisite() ) { |
675 | | update_user_status( $user_id, 'spam', $is_spam ); |
676 | | } |
| 705 | bp_core_update_member_status( $user_id, $is_spam ); |
677 | 706 | } |
678 | 707 | |
679 | 708 | // Update the user status. |
diff --git tests/phpunit/testcases/blogs/functions.php tests/phpunit/testcases/blogs/functions.php
index 4cd38a897..92804a647 100644
|
|
class BP_Tests_Blogs_Functions extends BP_UnitTestCase { |
291 | 291 | $this->setExpectedDeprecated( 'wpmu_new_blog' ); |
292 | 292 | } |
293 | 293 | |
294 | | if ( is_multisite() && function_exists( 'wp_get_registered_image_subsizes' ) ) { |
295 | | $this->setExpectedDeprecated( 'update_user_status' ); |
296 | | } |
297 | | |
298 | 294 | // Create a regular member |
299 | 295 | $u = self::factory()->user->create(); |
300 | 296 | |
diff --git tests/phpunit/testcases/core/class-bp-user-query.php tests/phpunit/testcases/core/class-bp-user-query.php
index d589f5a53..c03ad3076 100644
|
|
class BP_Tests_BP_User_Query_TestCases extends BP_UnitTestCase { |
389 | 389 | * @group spam |
390 | 390 | */ |
391 | 391 | public function test_bp_user_query_type_alphabetical_spam_xprofileoff() { |
392 | | if ( is_multisite() && function_exists( 'wp_get_registered_image_subsizes' ) ) { |
393 | | $this->setExpectedDeprecated( 'update_user_status' ); |
394 | | } |
395 | | |
396 | 392 | $u1 = self::factory()->user->create(); |
397 | 393 | $u2 = self::factory()->user->create(); |
398 | 394 | |
diff --git tests/phpunit/testcases/members/functions.php tests/phpunit/testcases/members/functions.php
index cd261ae24..e2492116c 100644
|
|
class BP_Tests_Members_Functions extends BP_UnitTestCase { |
378 | 378 | $this->markTestSkipped(); |
379 | 379 | } |
380 | 380 | |
381 | | if ( is_multisite() && function_exists( 'wp_get_registered_image_subsizes' ) ) { |
382 | | $this->setExpectedDeprecated( 'update_user_status' ); |
383 | | } |
384 | | |
385 | 381 | $bp = buddypress(); |
386 | 382 | $displayed_user = $bp->displayed_user; |
387 | 383 | |
… |
… |
class BP_Tests_Members_Functions extends BP_UnitTestCase { |
389 | 385 | $bp->displayed_user->id = $u1; |
390 | 386 | |
391 | 387 | // Bulk spam in network admin uses update_user_status |
392 | | update_user_status( $u1, 'spam', '1' ); |
| 388 | bp_core_update_member_status( $u1, '1' ); |
393 | 389 | |
394 | 390 | $this->assertTrue( bp_is_user_spammer( $u1 ) ); |
395 | 391 | |
… |
… |
class BP_Tests_Members_Functions extends BP_UnitTestCase { |
410 | 406 | $this->markTestSkipped(); |
411 | 407 | } |
412 | 408 | |
413 | | if ( is_multisite() && function_exists( 'wp_get_registered_image_subsizes' ) ) { |
414 | | $this->setExpectedDeprecated( 'update_user_status' ); |
415 | | } |
416 | | |
417 | 409 | $bp = buddypress(); |
418 | 410 | $displayed_user = $bp->displayed_user; |
419 | 411 | |
… |
… |
class BP_Tests_Members_Functions extends BP_UnitTestCase { |
426 | 418 | $this->assertTrue( bp_is_user_spammer( $u1 ) ); |
427 | 419 | |
428 | 420 | // Bulk unspam in network admin uses update_user_status |
429 | | update_user_status( $u1, 'spam', '0' ); |
| 421 | bp_core_update_member_status( $u1, '0' ); |
430 | 422 | |
431 | 423 | $this->assertFalse( bp_is_user_spammer( $u1 ) ); |
432 | 424 | |
… |
… |
class BP_Tests_Members_Functions extends BP_UnitTestCase { |
438 | 430 | * @group bp_core_process_spammer_status |
439 | 431 | */ |
440 | 432 | public function test_bp_core_process_spammer_status_make_spam_user_filter() { |
441 | | if ( is_multisite() && function_exists( 'wp_get_registered_image_subsizes' ) ) { |
442 | | $this->setExpectedDeprecated( 'update_user_status' ); |
443 | | } |
444 | | |
445 | 433 | add_filter( 'make_spam_user', array( $this, 'notification_filter_callback' ) ); |
446 | 434 | |
447 | 435 | $u1 = self::factory()->user->create(); |
… |
… |
class BP_Tests_Members_Functions extends BP_UnitTestCase { |
454 | 442 | } |
455 | 443 | |
456 | 444 | public function test_bp_core_process_spammer_status_make_ham_user_filter() { |
457 | | if ( is_multisite() && function_exists( 'wp_get_registered_image_subsizes' ) ) { |
458 | | $this->setExpectedDeprecated( 'update_user_status' ); |
459 | | } |
| 445 | $u1 = self::factory()->user->create(); |
| 446 | $s = bp_core_process_spammer_status( $u1, 'spam' ); |
460 | 447 | |
461 | 448 | add_filter( 'make_ham_user', array( $this, 'notification_filter_callback' ) ); |
462 | 449 | |
463 | | $u1 = self::factory()->user->create(); |
464 | | $n = bp_core_process_spammer_status( $u1, 'ham' ); |
| 450 | $h = bp_core_process_spammer_status( $u1, 'ham' ); |
465 | 451 | |
466 | 452 | remove_filter( 'make_ham_user', array( $this, 'notification_filter_callback' ) ); |
467 | 453 | |
… |
… |
class BP_Tests_Members_Functions extends BP_UnitTestCase { |
470 | 456 | } |
471 | 457 | |
472 | 458 | public function test_bp_core_process_spammer_status_bp_make_spam_user_filter() { |
473 | | if ( is_multisite() && function_exists( 'wp_get_registered_image_subsizes' ) ) { |
474 | | $this->setExpectedDeprecated( 'update_user_status' ); |
475 | | } |
476 | | |
477 | 459 | add_filter( 'bp_make_spam_user', array( $this, 'notification_filter_callback' ) ); |
478 | 460 | |
479 | 461 | $u1 = self::factory()->user->create(); |
… |
… |
class BP_Tests_Members_Functions extends BP_UnitTestCase { |
486 | 468 | } |
487 | 469 | |
488 | 470 | public function test_bp_core_process_spammer_status_bp_make_ham_user_filter() { |
489 | | if ( is_multisite() && function_exists( 'wp_get_registered_image_subsizes' ) ) { |
490 | | $this->setExpectedDeprecated( 'update_user_status' ); |
491 | | } |
492 | | |
493 | 471 | add_filter( 'bp_make_ham_user', array( $this, 'notification_filter_callback' ) ); |
494 | 472 | |
495 | 473 | $u1 = self::factory()->user->create(); |