2017-03-06 28 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