【问题标题】:Change Review Display Name on Woo-commerce Store在 Woo-commerce Store 上更改评论显示名称
【发布时间】:2017-03-07 09:51:19
【问题描述】:
【问题讨论】:
标签:
wordpress
woocommerce
review
【解决方案1】:
好的,我想通了。如果您没有子主题,则需要将代码发布到 functions.php 文件中。建议您设置一个,但我还没有,我只是想先解决这个问题。这是您需要的快照。
将以下文本块添加到底部或外观 > 编辑器中的 custom-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