2017-04-04 51 views
2

我知道有another post在這個題目。不幸的是我找不到解決方案。所以我再次問這個問題。WordPress的 - get_comment_author()返回 「匿名」 爲作者姓名

形勢

由被回報「無名氏」記錄爲作者姓名用戶的評論。即使填寫了評論表單中的相應字段。

代碼

這是怎樣的作者名稱顯示(從functions.php

<?php 
    /* translators: 1: comment author url, 2: comment author name, 3: comment permalink, 4: comment date/timestamp*/ 
    printf(__('%2$s schrieb am %4$s', 'buddypress'), get_comment_author_url(), get_comment_author(), get_comment_link(), get_comment_date()); 
?> 

文件可能會有所幫助:

我真的不知道如何甚至會找問題。 我從閱讀StackOverflow的類似問題的猜測是,我必須將評論ID傳遞給get_comment_author()。但在這種情況下,我不知道如何做到這一點。

任何幫助非常感謝!謝謝!

+0

你嘗試使用全局變量數組設置和訪問評論ID? $ GLOBALS [「comment_id」] =無;然後訪問它$ commentID = $ GLOBALS [「comment_id」]; – brad

回答

0

get_comment_author()如果$comment->comment_author爲空或者評論ID未傳遞給函數(默認爲0),則返回「匿名」。

在你的functions.php,儘量明確地設置ID:

$cID = $comment->comment_ID; 
printf(__('%2$s schrieb am %4$s', 'buddypress'), get_comment_author_url($cID), get_comment_author($cID), get_comment_link($cID), get_comment_date('',$cID)); 

如果這不起作用,則名稱不被存儲在$comment->comment_author

+0

你說得對。我已經嘗試像你提到的設置ID,但我仍然得到「匿名」。 我現在可能看的任何建議? – Arrowcatch

+0

您是否嘗試聯繫主題作者的支持? – Spartacus

+0

是的。主題不再在發展中。此外,我改變了很多東西,這幾乎是我現在的主題。也許我只會僱人來解決這個問題。但非常感謝您的幫助! :-) – Arrowcatch