Loading... ## 前言 最近看到《互联网用户账号信息管理规定》里面有说要求显示用户的归属地,现在很多软件、平台的评论区都出现了显示用户的归属地了,个人网站也必须要有显示才得。 这次用到[“松鼠大大”](https://doge.uk/)写的[UserAgent](https://doge.uk/coding/useragent-modify.html)插件。当然,别的UserAgent插件也是可以的。 ## 操作 1. 插件使用 下载好插件之后,重命名好,然后启用就可以了。 我们可以看到插件中提示,需要在显示的地方插入下面的代码: `<?php UserAgent_Plugin::get_useragent($comments->agent,$comments->ip); ?>` 1. 代码添加 我是直接添加在评论用户的昵称旁边。因此我需要修改主题文件的评论区代码,我用的是handsome主题,评论区在comments.php文件中。 在相应位置添加引用代码就可以了: ``` <span class="comment-author vcard"> <b class="fn"><?php echo $author; ?></b> <?php UserAgent_Plugin::get_useragent($comments->agent,$comments->ip); ?> <?php if (!($GLOBALS["off_star_comment"] == "true" || Utils::getExpertValue("off_star_comment"))):?> ``` 最后修改:2024 年 01 月 20 日 © 允许规范转载 赞 如果觉得我的文章对你有用,请随意赞赏