How to Change the Review Author Display Name in WooCommerce (stop using full name!)

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.”

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…

16 thoughts on “How to Change the Review Author Display Name in WooCommerce (stop using full name!)”

  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?

    • 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?


      • 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.

  3. This worked perfectly but for some reason if the Full First and Last name is not already chosen as the Display Publicly then it shows “Anonymous” which is not good. If someone has 10k users you’d be sitting there all day.

    You would probably need a script to force the Display name to use First & Last

    • Hi Stef,

      Yes this is outside of the scope of this function. If you don’t have names set, then this function wouldn’t work. The object of this little snippet is to stop showing full name of a buyer in reviews, which people can get antsy about (I don’t necessarily want my full name to show up – it might put me off posting a review at all!). Its most appropriate when reviews are left by genuine buyers only.

      This script quite literally sets the author to “Anonymous” if the user did not have a user account (i.e. on guest posted reviews). You can change “anonymous” to be something else, like “guest review” or make it use the comment name details provided.

      That’s beyond the scope of this snippet, but it shouldn’t be too hard to figure out… alas I’m deep in some other tasks right now, but another commentor might post this up… or I’ll circle back later and see what I can dream up!

      Good luck!

    • Thanks for the comment – have pushed this code into a Gist, which should work a lot better. Its something we’ve been doing site-wide, but your comment did help to highlight one that got away 🙂

  4. Hello, thank you very much for your contribution.
    I want to get the first letter of the author’s name and surname. Then I want to show this in the comments too. How should I make a change in the code?
    For example;
    Author: Robin Scott
    Name in the comments:
    It should be R **** S ***.
    Thank you in advance for your interest.

  5. Hello !
    Thanks for this contribution 🙂

    I’ve tried this code and it works very well but an error appears above the name in debug mode :
    “Notice: Undefined variable: comment_ID in /www/websitefolder/public/wp-content/themes/hello-elementor-child/functions/woocommerce.php on line 190

    Any idea on a way to solve this please ?

    Thank you in advance for your help !

    • Change the filter to:
      add_filter(‘get_comment_author’, ‘my_comment_author’, 10, 3);

      And the function to:
      function my_comment_author($author, $comment_ID, $comment)

      It should remove the warnings


Leave a comment

No links of any kind allowed in comments - if you add any links, your comment will automatically be deleted.