How to make real product review name format match imported product review name format


Active Member
When you import product reviews using AliDropship it uses the first name of the buyer with everything apart from the first and last letters replaced with asterisks. For example Katherine becomes K*******e and Mar would become M*r.

When a review is added from the front end of your site it doesn't display like the above, instead it shows the full buyer name. Therefore it looks strange because they are displayed differently and can lead customers to wonder why their review appears differently.

To get around this, you can add the below function which will modify the review author (aka the WordPress comment author) to show only the first name and with the asterisks as per AliDropship. Unless you allow anonymous reviews (which I wouldn't recommend) in which case it will display the author as 'Anonymous'.

function my_comment_author( $author, $comment_id, $comment ) {
    // NOT empty
    if ( $comment ) {
        // Get user id
        $user_id = $comment->user_id;

        // User id exists
        if( $user_id > 0 ) {
            // Get user data
            $user = get_userdata( $user_id );

            // User first name
            $user_first_name = $user->first_name;

            // Call function
            $author = replace_with_stars( $user_first_name );      
        } else {
            $author = __('Anonymous', 'woocommerce');

    return $author;
add_filter('get_comment_author', 'my_comment_author', 10, 3 );

function replace_with_stars( $str ) {
    // Returns the length of the given string.
    $len = strlen( $str );

    return substr( $str, 0, 1 ).str_repeat('*', $len - 2).substr( $str, $len - 1, 1 );

I use this on my sites and haven't had any issues.

Note that I haven't used any official AliDropship themes on my sites which might already address this.