修复wpdiscuz头像无法跳转的问题-为每条评论的头像指定到对应的个人资料页面

上期我们解决了归档页面重定向问题,不过评论系统因为与个人资料表单不兼容问题,目前只能将管理员的Avatar 添加href,还是无法自动为其他用户组的avatar 添加href。今天就来修复这个问题。

在wpdiscuz设置中 开启Enable Profiles URL选项,通过查找表单login["enableProfileURLs"] 在class.WpdiscuzHelper下找到getMentionedUsers、getCommentAuthor函数

发现在getCommentAuthor函数下有一段代码结果有误(不是逻辑有误-应该是表单不兼容问题导致的)。

原代码如下:

$user["profileUrl"] = in_array($user["user"]->ID, $args["posts_authors"]) ? get_author_posts_url($user["user"]->ID) : ''

in_array查询ID是否在posts_authors数组中, 得出结果id不存在数组中,走了else语句。这里猜测主要是args参数赋值时候  posts_authors元素 获取有误。这里笔者想要让每条评论的头像都能跳转到对应的个人中心,所以这里就直接修改了此处逻辑,无论是否存在都直接跳转。

修改后代码如下

/*$user["profileUrl"] = in_array($user["user"]->ID, $args["posts_authors"]) ? get_author_posts_url($user["user"]->ID) : ''*/
//rewrite modify problem: 'comment avatar-Href noLink which are member account ';
$user["profileUrl"] = in_array($user["user"]->ID, $args["posts_authors"]) ? get_author_posts_url($user["user"]->ID) : get_author_posts_url($user["user"]->ID);

修改此处代码评论下的所有 avatar link都正常了。

 

作者:Miracle
来源:麦瑞克博客
链接:https://www.playcreator.cn/archives/blog_construction/912/
本博客所有文章除特别声明外,均采用CC BY-NC-SA 4.0许可协议,转载请注明!
THE END
分享
海报
修复wpdiscuz头像无法跳转的问题-为每条评论的头像指定到对应的个人资料页面
上期我们解决了归档页面重定向问题,不过评论系统因为与个人资料表单不兼容问题,目前只能将管理员的Avatar 添加href,还是无法自动为其他用户组的avatar 添加……
<<上一篇
下一篇>>
文章目录
关闭
目 录