WooCommerce: Change Review Author Display Name from Username

Robin ScottWooCommerce Tutorials7 Comments

Have you ever wanted to change the way that WooCommerce reviews are displayed in your store?

The code below, when added to your theme’s functions.php file will allow you to change comment author display from username to first name and last initial with a . after it.

Please note, you can always change this to suit your needs! The code should be a good starting point, however.

Also note, this may change how regular comment authors names display, but only if they are registered and logged in user’s comments…

Change WooCommerce Review Author Display Name from Username to “FirstName L.”

add_filter('get_comment_author', 'my_comment_author', 10, 1);

function my_comment_author( $author = '' ) {
// Get the comment ID from WP_Query
$comment = get_comment( $comment_ID );
if (!empty($comment->comment_author) ) {
if($comment->user_id > 0){
$author=$user->first_name.' '.substr($user->last_name,0,1).'.'; // this is the actual line you want to change
} else {
$author = __('Anonymous');
} else {
$author = $comment->comment_author;

return $author;

Leave a comment below if this helped you get this done. If you’d like clarification, feel free to ask in the comments, too. If you want to book us to complete some WooCommerce customisation or other, contact us!

Happy woocommercing…

7 Comments on “WooCommerce: Change Review Author Display Name from Username”

  1. Hi there,

    This certainly works but it also changes the way customer names are displayed for the backend admin which makes searching for a customer or adding a customer order in the backend very difficult.

    Any workaround for that?

    1. Hi Leanne,

      It shouldn’t change the way customer names are displayed in admin. This code changes the “comment author” part on the *front end* of the website. It does not alter the way usernames / firstnam last name are shown in WooCommerce. Perhaps you installed something else that does that?


      1. Can confirm I just installed this function on this website (it altered my name, but the username / buyer name in woocommerce remains the same as it was, first name, last name.).

        My comment author name, though, showed as Robin S., as this code intended.

        Tested and works. You have something else changing user name in wooocommerce / WP admin!

  2. Thanks for your reply Robin 🙂

    I will have to investigate what is causing that to change in the backend but your code certainly works well for the front end.

    Do you know how I could expand on your code to show the first name and last name initial for everyone except administrators? I would like to be able to display replies as Customer Service – of course your code currently works as promised and shows Customer S.

    Appreciate your advice.

Leave a Reply

Your email address will not be published. Required fields are marked *