WordPress.org

Plugin Directory

Restrict Usernames

Restrict the usernames that new users may use when registering for your site.

Filters

The plugin exposes one filter for hooking. Typically, customizations utilizing this hook would be put into your active theme's functions.php file, or used by another plugin.

c2c_restrict_usernames-validate (filter)

The 'c2c_restrict_usernames-validate' hook allows you to add your own customized checks for the username being registered. You can add additional restrictions or override the assessment performed by the plugin.

Arguments:

  • $valid (boolean): The assessment by the plugin about the validity of the username based on settings. True means username can be used.
  • $username (string): The username being registered.
  • $settings (array): The plugin's settings.

Example:

/**
 * Add custom checks on usernames.
 *
 * Specifically, prevent use of usernames ending in numbers.
 */
function my_restrict_usernames_check( $valid, $username, $options ) {
    // Only do additional checking if the plugin has already performed its
    // checks and deemed the username valid.
    if ( $valid ) {
        // Don't allow usernames to end in numbers.
        if ( preg_match( '/[0-9]+$/', $username ) )
            $valid = false;
    }
    return $valid;
}
add_filter( 'c2c_restrict_usernames-validate', 'my_restrict_usernames_check', 10, 3 );

Requires: 3.6 or higher
Compatible up to: 4.2.1
Last Updated: 2015-4-17
Active Installs: 1,000+

Ratings

3.4 out of 5 stars

Support

1 of 3 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1
100,1,1 100,3,3
100,1,1
100,1,1
100,1,1
67,3,2
100,1,1
50,2,1
0,2,0 100,1,1
50,2,1
50,2,1
50,2,1
100,1,1
100,1,1
100,1,1