Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/16/2017 08:00:41 PM (2 years ago)
Author:
boonebgorges
Message:

Members: Run BP's illegal user names through WP filter.

This ensures that user names added to the blacklist via the
'illegal_user_logins' filter are also blacklisted during BP registration.

Props espellcaste.
Fixes #7461.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/members/functions.php

    r11737 r11747  
    638638        $wpdb->suppress_errors( $suppress );
    639639    }
     640
     641    /**
     642     * @ticket BP7461
     643     *
     644     * Test function before and after adding custom illegal names from WordPress.
     645     */
     646    public function test_bp_core_get_illegal_names() {
     647
     648        // Making 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        // Making 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    public function _illegal_user_logins() {
     667        return array(
     668            'testuser',
     669            'admins',
     670            'buddypress',
     671        );
     672    }
    640673}
Note: See TracChangeset for help on using the changeset viewer.