Site logo

Archived topic

Woo product reviews disclose customer's full name

4 replies · Started by Sven on June 3, 2017

Viewing posts 1–5 of 5

Hi there,

I may have found a potential privacy issue with the theme being the product reviews show the customer's full name. I suggest to only display the first name as that should suffice for a public review? I'm using the Statement child theme.

Best regards

Hi there,

That should be handled by WooCommerce, not the theme. If there's no option in the WooCommerce settings for that, it might be worth asking their support if they have a solution.

Ah, I see! Sorry for the hickup then.

If anyone else is stumbling upon this, here's the code to fix it:

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){
$user=get_userdata($comment->user_id);
$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;
}

Credit:
https://silicondales.com/tutorials/woocommerce-tutorials/woocommerce-change-review-author-display-name-username/

Thanks for posting the solution! :)

This archived topic is closed to new replies.