Keyword

Disabling email field as a required field for comments?

  • Bostjan Cadej
  • Bostjan Cadej's Avatar Topic Author
  • Offline
  • Junior Member
More
9 years 3 weeks ago - 9 years 3 weeks ago #153422 by Bostjan Cadej
I have a K2 v2.7.0 site with comments enabled for everyone. When the users leave comments they are required to enter their name and email and optionally url. I want to make the email field also optional (not required). How can I do that?

Thanks!
Last edit: 9 years 3 weeks ago by Bostjan Cadej.

Please Log in or Create an account to join the conversation.

  • JoomlaWorks Support Team
  • JoomlaWorks Support Team's Avatar
  • Offline
  • Elite Member
More
9 years 3 weeks ago - 9 years 3 weeks ago #153439 by JoomlaWorks Support Team
Replied by JoomlaWorks Support Team on topic Disabling email field as a required field for comments?
Hi,
The validation of the email is located at the components/com_k2/models/item.php
if (empty($userName) || $userName == JText::_('K2_ENTER_YOUR_NAME') || empty($commentText) || $commentText == JText::_('K2_ENTER_YOUR_MESSAGE_HERE') || empty($commentEmail) || $commentEmail == JText::_('K2_ENTER_YOUR_EMAIL_ADDRESS'))
{
	$response->message = JText::_('K2_YOU_NEED_TO_FILL_IN_ALL_REQUIRED_FIELDS');
	$response->cssClass = 'k2FormLogError';
	echo $json->encode($response);
	$mainframe->close();
}

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

Have in mind that you will hack the core by doing this.
Last edit: 9 years 3 weeks ago by JoomlaWorks Support Team.

Please Log in or Create an account to join the conversation.

  • Bostjan Cadej
  • Bostjan Cadej's Avatar Topic Author
  • Offline
  • Junior Member
More
9 years 3 weeks ago #153472 by Bostjan Cadej
Hi Teo,

I'm not looking for validation, I'm looking for field being required or not - obligatory or not.
Where can I set that (for email filed in this form)?

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 3 weeks ago #153486 by Krikor Boghossian
Replied by Krikor Boghossian on topic Disabling email field as a required field for comments?
Validation is what you are looking for.
Since the field is required, a validation script will always run.

By removing the code Teo mentioned, the email field will not be required as it is by default.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum