2017-01-09 38 views
0

我想告訴我的WordPress網站的內環路評論作者個人資料鏈接。如何打印評論作者個人資料鏈接

我試過get_comment_author_url(),但它顯示的評論作者的Facebook的個人主頁的鏈接,而不是我想打印在我的WordPress網站他的個人資料鏈接。

最終的結果應該是這樣的example.com/author/john-smith

我不能只打印的綽號,因爲John Smith(駱駝的情況下,空間)是暱稱和顯示的名稱,它應該被格式化(用戶可能有口音命名或特殊字符)。

回答

0

功能force_comment_author_url($評論) {// 不評論有一個有效的作者網址? $ no_url!= $ comment-> comment_author_url || $ comment-> comment_author_url ==的 'http://';

if ($comment->user_id && $no_url) { 
    // comment was written by a registered user but with no author URL 
    $comment->comment_author_url = 'http://www.example.com/?author=' . $comment->user_id; 
} 
return $comment; 

} 的add_filter( 'get_comment', 'force_comment_author_url');

相關問題