WordPress Comments – Only show part of user name

You have to dive into comment template in your theme and find out the line where username is printed. Then use the following function in functions.php:

function alter_username( $username ){
    return substr( $username, 0, 1 ). str_repeat( '*', strlen( $username ) - 2 ) . substr( $username, strlen( $username ) - 1 ,1 );
}

Then use the function in comment template or wherever you want to show altered username like:

echo alter_username( $username );