如何使电子邮件字段在Joomla K2评论中变得不需要



我有一个k2 joomla模板,在文章下,有一个带有评论表单的评论模块。在窗体上,电子邮件已添加并设置为必需。但是,我不想使电子邮件成为必需的,只是可选的。我该如何解决这个问题?

提前致谢

最简单的方法:打开/components/com_k2/models/item.php。

在第 1125 行周围,找到以下块:

$userName = trim($row->userName);
$commentEmail = trim($row->commentEmail);
$commentText = trim($row->commentText);
$commentURL = trim($row->commentURL);

在以下位置插入:

if ($row->commentEmail==''){
    $row->commentEmail='guest@guest.com';
}

在安装中打开以下文件: componentscom_k2modelsitem.php

然后删除或注释掉以下行。

if (!JMailHelper::isEmailAddress($commentEmail) AND $commentEmail !=  JText::_('K2_ENTER_YOUR_EMAIL_ADDRESS'))
        {
            $response->message = JText::_('K2_INVALID_EMAIL_ADDRESS');
            echo $json->encode($response);
            $mainframe->close();
        }

相关内容