Filter hook 'pre_user_nicename'

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

View Source

pre_user_nicename

Filter Hook
Description
Filters a user's nicename before the user is created or updated.

Hook Information

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

Hook Parameters

Type Name Description
string $user_nicename The user's nicename.

Usage Examples

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

function my_custom_filter($user_nicename) {
    // Your custom filtering logic here
    return $user_nicename;
}

Source Code Context

wp-includes/user.php:2281 - How this hook is used in WordPress core
<?php
2276  	 *
2277  	 * @since 2.0.3
2278  	 *
2279  	 * @param string $user_nicename The user's nicename.
2280  	 */
2281  	$user_nicename = apply_filters( 'pre_user_nicename', $user_nicename );
2282  
2283  	if ( mb_strlen( $user_nicename ) > 50 ) {
2284  		return new WP_Error( 'user_nicename_too_long', __( 'Nicename may not be longer than 50 characters.' ) );
2285  	}
2286  

PHP Documentation

<?php
/**
	 * Filters a user's nicename before the user is created or updated.
	 *
	 * @since 2.0.3
	 *
	 * @param string $user_nicename The user's nicename.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/user.php
Related Hooks

Related hooks will be displayed here in future updates.