Filter hook 'validate_username'

in WP Core File wp-includes/user.php at line 2122

View Source

validate_username

Filter Hook
Description
Filters whether the provided username is valid.

Hook Information

File Location wp-includes/user.php View on GitHub
Hook Type Filter
Line Number 2122

Hook Parameters

Type Name Description
bool $valid Whether given username is valid.
string $username Username to check.

Usage Examples

Basic Usage
<?php
// Hook into validate_username
add_filter('validate_username', 'my_custom_filter', 10, 2);

function my_custom_filter($valid, $username) {
    // Your custom filtering logic here
    return $valid;
}

Source Code Context

wp-includes/user.php:2122 - How this hook is used in WordPress core
<?php
2117  	 * @since 2.0.1
2118  	 *
2119  	 * @param bool   $valid    Whether given username is valid.
2120  	 * @param string $username Username to check.
2121  	 */
2122  	return apply_filters( 'validate_username', $valid, $username );
2123  }
2124  
2125  /**
2126   * Inserts a user into the database.
2127   *

PHP Documentation

<?php
/**
	 * Filters whether the provided username is valid.
	 *
	 * @since 2.0.1
	 *
	 * @param bool   $valid    Whether given username is valid.
	 * @param string $username Username to check.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/user.php
Related Hooks

Related hooks will be displayed here in future updates.