K2 Comment User Error
I was trying to put a smart ass comment on one of my own articles rather than login and just update the whole thing and – lo and behold it turned into a code editing pain in the ass!!
Amazing!! Seems like almost everything I try on the computer these days turns to shit. (Just wait for the Virtualmin Moodle fiasco!)
Anyway, I found the problem and what I needed to do to remedy it so if you aren’t already looking at the main page click Read More to see what it is.
The “Error” you are seeing in the first picture is actually just a message to tell you that the user is already registered with the site. (Before I get into it, this solution came from here.) So what I did was simply change the message. (See below) However, you can also comment out the section of code that calls for the K2 comments to look up the user in the database.
Open up FileZilla or whatever you use to access your files and open up:
“Your_Joomla_installation_directory/components/com_k2/models/item.php” with your editor of choice.
There locate and comment out the following code: (I just searched for “loadresult“)
if ($user->guest){
$db = & JFactory::getDBO();
$query = “SELECT COUNT(*) FROM #__users WHERE name=”.$db->Quote($userName).” OR email=”.$db->Quote($commentEmail);
$db->setQuery($query);
$result = $db->loadresult();
if ($result>0){
echo JText::_(‘The name or email address you typed is already in use!‘);
$mainframe->close();
}
}
In other words add the /* at the beginning and */ at the end of the statement.
/*if ($user->guest){
$db = & JFactory::getDBO();
$query = “SELECT COUNT(*) FROM #__users WHERE name=”.$db->Quote($userName).” OR email=”.$db->Quote($commentEmail);
$db->setQuery($query);
$result = $db->loadresult();
if ($result>0){
echo JText::_(‘The name or email address you typed is already in use!’);
$mainframe->close();
}
}*/
What I did, was rewrite the warning to tell the user what the hell was going on. As in this second picture.
One weird thing was, when I opened the file, the warning was all in uppercase words separated by underscores. Leaving it as is and putting the file back – that’s the way the message showed up – all uppercase, connected by underscores – not the original message. Rewriting it as below gives me that, so I don’t know what made the rewrite, but it works now. Whatever!!