2017-03-06 27 views
0

我希望能够更改在woocommerce平台上显示评论的名称。我发现了一些信息,但我是WordPress新手,似乎没有人能够得到答案。这是一个链接,我能够找到一些东西,但没有安装细节。更改评论在Woo-commerce商店的显示名称

我需要知道在哪里以及如何改变这个请。谢谢。

这是我找到的链接。

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

我已经加入了一个名为用户名换插件,它让我改变帐户的用户名,但它不会更新审查的用户名。

这里有一些图像作为的现在(2017年3月6日)

的用户是如何被配置为与用户名编辑快照:

Snapshot of how user is configured with edited username

回答

0

确定我已经计算出来。如果您没有子主题,则需要将代码发布到functions.php文件中。建议您设置一个,但我还没有,我只是想先弄清楚这个问题。以下是您需要的快照。

文字的下面的框添加到底部或您的自定义的functions.php或页面functions.php的外观之内>编辑

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; 
} 

确保更新用户信息。

Missing Sections from the Original Question