Ticket #7461: 7461.diff
| File 7461.diff, 3.7 KB (added by , 8 years ago) |
|---|
-
src/bp-members/bp-members-functions.php
diff --git src/bp-members/bp-members-functions.php src/bp-members/bp-members-functions.php index 462f1d12d..7846718ee 100644
function bp_core_get_illegal_names( $value = '', $oldvalue = '' ) { 1556 1556 'settings', 1557 1557 'notifications', 1558 1558 'register', 1559 'activate' 1559 'activate', 1560 1560 ); 1561 1561 1562 1562 // Core constants. … … function bp_core_get_illegal_names( $value = '', $oldvalue = '' ) { 1574 1574 'BP_REGISTER_SLUG', 1575 1575 'BP_ACTIVATION_SLUG', 1576 1576 ); 1577 foreach ( $slug_constants as $constant ) {1577 foreach ( $slug_constants as $constant ) { 1578 1578 if ( defined( $constant ) ) { 1579 1579 $bp_component_slugs[] = constant( $constant ); 1580 1580 } 1581 1581 } 1582 1582 1583 1583 /** 1584 * Filters the array of default illegal usernames .1584 * Filters the array of default illegal usernames from BuddyPress. 1585 1585 * 1586 1586 * @since 1.2.2 1587 1587 * 1588 1588 * @param array $value Merged and unique array of illegal usernames. 1589 1589 */ 1590 $filtered_illegal_names = apply_filters( 'bp_core_illegal_usernames', array_merge( array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ), $bp_component_slugs ) );1590 $filtered_illegal_names = (array) apply_filters( 'bp_core_illegal_usernames', array_merge( array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ), $bp_component_slugs ) ); 1591 1591 1592 // Merge the arrays together. 1593 $merged_names = array_merge( (array) $filtered_illegal_names, (array) $db_illegal_names ); 1592 /** 1593 * Filters the list of illegal usernames from WordPress. 1594 * 1595 * @since 3.0 1596 * 1597 * @param array Array of illegal usernames. 1598 */ 1599 $wp_filtered_illegal_names = apply_filters( 'illegal_user_logins', array() ); 1600 1601 // First merge BuddyPress illegal names. 1602 $bp_merged_names = array_merge( (array) $filtered_illegal_names, (array) $db_illegal_names ); 1603 1604 // Then merge WordPress and BuddyPress illegal names. 1605 $merged_names = array_merge( (array) $wp_filtered_illegal_names, (array) $bp_merged_names ); 1594 1606 1595 1607 // Remove duplicates. 1596 $illegal_names = array_unique( (array) $merged_names );1608 $illegal_names = array_unique( (array) $merged_names ); 1597 1609 1598 1610 /** 1599 1611 * Filters the array of default illegal names. -
tests/phpunit/testcases/members/functions.php
diff --git tests/phpunit/testcases/members/functions.php tests/phpunit/testcases/members/functions.php index 823df65e8..941927f16 100644
class BP_Tests_Members_Functions extends BP_UnitTestCase { 637 637 638 638 $wpdb->suppress_errors( $suppress ); 639 639 } 640 641 /** 642 * @ticket BP7461 643 * 644 * Test function before and after adding custom illegal names from WordPress. 645 */ 646 function test_bp_core_get_illegal_names() { 647 648 // Marking sure BP custom illegals are in the array. 649 $this->assertTrue( in_array( 'profile', bp_core_get_illegal_names(), true ) ); 650 $this->assertTrue( in_array( 'forums', bp_core_get_illegal_names(), true ) ); 651 652 add_filter( 'illegal_user_logins', array( $this, '_illegal_user_logins' ) ); 653 654 // Testing fake custom illegal names. 655 $this->assertTrue( in_array( 'testuser', bp_core_get_illegal_names(), true ) ); 656 $this->assertTrue( in_array( 'admins', bp_core_get_illegal_names(), true ) ); 657 $this->assertFalse( in_array( 'buddypresss', bp_core_get_illegal_names(), true ) ); 658 659 // Marking sure BP custom illegals are in the array after including the custom ones. 660 $this->assertTrue( in_array( 'profile', bp_core_get_illegal_names(), true ) ); 661 $this->assertTrue( in_array( 'forums', bp_core_get_illegal_names(), true ) ); 662 663 remove_filter( 'illegal_user_logins', array( $this, '_illegal_user_logins' ) ); 664 } 665 666 function _illegal_user_logins() { 667 return array( 'testuser', 'admins', 'buddypress' ); 668 } 640 669 }