By default, Typecho does not have the functionality to mention (@) the commenter in comments. You can add the following code to enable it.
In functions.php
:
/*
* Reply to comments with @ mention
*/
function get_comment_at($coid)
{
$db = Typecho_Db::get();
$prow = $db->fetchRow($db->select('parent,status')->from('table.comments')
->where('coid = ?', $coid));
$mail = "";
$parent = @$prow['parent'];
if ($parent != "0") {
$arow = $db->fetchRow($db->select('author,status,mail')->from('table.comments')
->where('coid = ?', $parent));
@$author = @$arow['author'];
$mail = @$arow['mail'];
if(@$author && $arow['status'] == "approved"){
if (@$prow['status'] == "waiting"){
echo '<p class="commentReview">(Comment under review)</p>';
}
echo '<a href="#comment-' . $parent . '">@' . $author . '</a>';
}else{
if (@$prow['status'] == "waiting"){
echo '<p class="commentReview">(Comment under review)</p>';
}else{
echo '';
}
}
} else {
if (@$prow['status'] == "waiting"){
echo '<p class="commentReview">(Comment under review)</p>';
}else{
echo '';
}
}
}
Then, add the following code before the output of the comment content in comments.php
:
<?php $parentMail = get_comment_at($comments->coid)?><?php echo $parentMail;?>
▼ Code example
▼ Result
My blog will soon be synchronized to Tencent Cloud+ Community. I invite everyone to join: https://cloud.tencent.com/developer/support-plan?invite_code=17ctk6evsjk5b