K2 Comment: Disabling email field as a required field for K2 comments

Tag: |   Category:

If you want to remove Email field as a required field from K2 comments, follow below steps...

Go to components/com_k2/models and open item.php.

Go to Line 1204, and delete below code

			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();
			}

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

If you want to remove Email * sign from the comment form. Go to templates/TEMPLATE/html/com_k2/default and open item_comments_form.php.

Go to Line 38, and delete the * sign.

<label class="formEmail" for="commentEmail"><?php echo JText::_('K2_EMAIL'); ?> *</label>
Copyright © 2024 Siam Naulak.
magnifiercrossmenu