add_filter return value

function validate_username( $username ) {
    $sanitized = sanitize_user( $username, true );
    $valid = ( $sanitized == $username );

    return apply_filters( 'validate_username', $valid, $username );
}

in wp-includes/registration.php i want to change

$sanitized = sanitize_user( $username, true );

to

Read More
$sanitized = sanitize_user( $username, false );

I couldnt success to write add_filter in there, somehow its not working. Can you write a filter for this please?

Related posts

Leave a Reply

2 comments

  1. Like so:

    function my_validate_username( $valid, $username ) {
        $sanitized = sanitize_user( $username, false );
        $valid = ( $sanitized == $username );
    
        return $valid;
    }
    
    add_filter('validate_username', 'my_validate_username', 10, 2);