Keyword

[HOW TO]: Captcha other than recaptcha

  • Michael
  • Michael's Avatar Topic Author
  • Offline
  • New Member
More
11 years 3 months ago - 11 years 3 months ago #114393 by Michael
Hi
My clients and I hate recaptcha! It is simply not user friendly.
I like EasyCalcCheck Plus or Are you human (PlayThru Captcha)!

Find them on joomla extensions.

Now, to implement them on K2:

See: www.fabbricabinaria.it/en/component/kunena/playthru-captcha/151-playthru-and-k2-login#.UbmgA-tkI1c

It works beautifully: Here is the post by Fritz:


Actually, it's not so difficult. If you happen to use a custom template, you can do it in a template override. Here is a short description (for K2's registration form, tested in Joomla 2.5.9):

Step 1:
In your custom template folder, create a sub-folder hierarchy named html/com_k2. E.g. If your curstom template is in templates/bos/, then the new folders path is templates/bos/html/com_k2

Step 2:
Copy K2's original registration form from components/com_k2/templates/register.php to the previously created folder. E.g: in the example above, that would be templates/bos/html/com_k2/register.php

Step 3:
Edit the copied file and find the single line that contains the closing table tag:

</table>



Step 4: Insert the following code snippet above that line:

<?php
if (!($this->K2Params->get('recaptchaOnRegistration') && $this->K2Params->get('recaptcha_public_key'))) {
$configured_captcha = JFactory::getApplication()->getParams()->get('captcha', JFactory::getConfig()->get('captcha'));
if (!empty($configured_captcha)) {
$jcaptcha = JCaptcha::getInstance($configured_captcha, array('namespace' => 'com_users.registration'));
if (!is_null($jcaptcha)) {
JRequest::setVar('session_secret', uniqid()); // Required by playthru captcha plugin
$ccode = $jcaptcha->display("jcaptcha", "jcaptcha", "required");
echo '<tr>' . "\n";
echo '<td class="key">' . JText::_('TPL_BOS_PLAYTHRU_CAPTCHA_LABEL') . "</td>\n";
echo "<td>" . $ccode . "</td>\n";
echo "<td> * </td>\n";
echo '</tr>' . "\n";
}
}
}
?>



Remarks:
In the code snippet above, there's a translation key TPL_BOS_PLAYTHRU_CAPTCHA_LABEL which represents the descriptive text left of the playthru captcha. In order to show desired text, you must create a file named language/overrides/en-GB.override.ini and put the following line into it:
TPL_BOS_PLAYTHRU_CAPTCHA_LABEL="Whatever text you like"


The code snippet is not specific to the playthru capcha. In fact, it simply uses whatever captcha plugin is configured globally in the backend.

In order to enable it, you have to disable K2's recaptcha option in the backend.

Hope this helps...
-Fritz

Note: on a joomlart T3 site with a template from joomlart, look under your template/html/com_k2 and look for the file register.php
Replace the code for the recaptcha with the code snippet from Fritz:

replace this code with the code snippet from Fritz:
<?php if($this->K2Params->get('recaptchaOnRegistration') && $this->K2Params->get('recaptcha_public_key')): ?>
<label class="formRecaptcha"><?php echo JText::_('K2_ENTER_THE_TWO_WORDS_YOU_SEE_BELOW'); ?></label>
<div id="recaptcha"></div>
<?php endif; ?>

See our site: www.illuminatenatmed.com

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 3 months ago #114394 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: [HOW TO]: Captcha other than recaptcha
Thanks Michael!!

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
11 years 3 months ago - 11 years 3 months ago #114395 by Leigh Bikechatter
Replied by Leigh Bikechatter on topic Re: [HOW TO]: Captcha other than recaptcha
I am going to test this now as simply adding the playthru captcha to my K2 user profile is a perfect solution to my current problem.

Devs, if this is as simple a fix as it gets for using the Joomla allocated captcha rather than the complexity of using one built into K2 is there any chance of getting this bit of code included within K2?

As I said in one of my previous posts it does not seem logical to have a captcha built into K2 that ignores the captcha a user elects to use on the rest of the site - especially when recaptcha seems to attract spammers rather than put them off.

***Edited, works perfectly! - here is my register.php from 2.6.7SVN - I have no use for description and user image so mine is as close to the Joomla fields as possible - just with the addition of gender to make the comments work.
<?php
/**
 * @version             $Id: register.php 1812 2013-01-14 18:45:06Z lefteris.kavadas $
 * @package             K2
 * @author              JoomlaWorks https://www.joomlaworks.net
 * @copyright   Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
 * @license             GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
 */

// no direct access
defined('_JEXEC') or die;

?>

<!-- K2 user register form -->
<?php if(isset($this->message)) $this->display('message'); ?>

<form action="<?php echo JURI::root(true); ?>/index.php" enctype="multipart/form-data" method="post" id="josForm" name="josForm" class="form-validate">
        <?php if($this->params->def('show_page_title',1)): ?>
        <div class="componentheading<?php echo $this->escape($this->params->get('pageclass_sfx')); ?>">
                <?php echo $this->escape($this->params->get('page_title')); ?>
        </div>
        <?php endif; ?>
        <div id="k2Container" class="k2AccountPage">
                <table class="admintable" cellpadding="0" cellspacing="0">
                        <tr>
                                <th colspan="2" class="k2ProfileHeading">
                                        <?php echo JText::_('K2_ACCOUNT_DETAILS'); ?>
                                </th>
                        </tr>
                        <tr>
                                <td class="key">
                                        <label id="namemsg" for="name"><?php echo JText::_('K2_NAME'); ?></label>
                                </td>
                                <td>
                                        <input type="text" name="<?php echo $this->nameFieldName; ?>" id="name" size="40" value="<?php echo $this->escape($this->user->get( 'name' )); ?>" class="inputbox required" maxlength="50" />
                                        *
                                </td>
                        </tr>
                        <tr>
                                <td class="key">
                                        <label id="usernamemsg" for="username"><?php echo JText::_('K2_USER_NAME'); ?></label>
                                </td>
                                <td>
                                        <input type="text" id="username" name="<?php echo $this->usernameFieldName; ?>" size="40" value="<?php echo $this->escape($this->user->get( 'username' )); ?>" class="inputbox required validate-username" maxlength="25" />
                                        *
                                </td>
                        </tr>
                        <tr>
                                <td class="key">
                                        <label id="emailmsg" for="email"><?php echo JText::_('K2_EMAIL'); ?></label>
                                </td>
                                <td>
                                        <input type="text" id="email" name="<?php echo $this->emailFieldName; ?>" size="40" value="<?php echo $this->escape($this->user->get( 'email' )); ?>" class="inputbox required validate-email" maxlength="100" />
                                        *
                                </td>
                        </tr>
                        <?php if(version_compare(JVERSION, '1.6', 'ge')): ?>
                        <tr>
                                <td class="key">
                                        <label id="email2msg" for="email2"><?php echo JText::_('K2_CONFIRM_EMAIL'); ?></label>
                                </td>
                                <td>
                                        <input type="text" id="email2" name="jform[email2]" size="40" value="" class="inputbox required validate-email" maxlength="100" />
                                        *
                                </td>
                        </tr>
                        <?php endif; ?>
                        <tr>
                                <td class="key">
                                        <label id="pwmsg" for="password"><?php echo JText::_('K2_PASSWORD'); ?></label>
                                </td>
                                <td>
                                        <input class="inputbox required validate-password" type="password" id="password" name="<?php echo $this->passwordFieldName; ?>" size="40" value="" />
                                        *
                                </td>
                        </tr>
                        <tr>
                                <td class="key">
                                        <label id="pw2msg" for="password2"><?php echo JText::_('K2_VERIFY_PASSWORD'); ?></label>
                                </td>
                                <td>
                                        <input class="inputbox required validate-passverify" type="password" id="password2" name="<?php echo $this->passwordVerifyFieldName; ?>" size="40" value="" />
                                        *
                                </td>
                        </tr>
                        <tr>
                                <th colspan="2" class="k2ProfileHeading">
                                        <?php echo JText::_('K2_PERSONAL_DETAILS'); ?>
                                </th>
                        </tr>
                        <!-- K2 attached fields -->
                        <tr>
                                <td class="key">
                                        <label id="gendermsg" for="gender"><?php echo JText::_('K2_GENDER'); ?>*</label>
                                </td>
                                <td>
                                        <?php echo $this->lists['gender']; ?>
                                </td>
                        </tr>
                        <?php if(count(array_filter($this->K2Plugins))): ?>
                        <!-- K2 Plugin attached fields -->
                        <tr>
                                <th colspan="2" class="k2ProfileHeading">
                                        <?php echo JText::_('K2_ADDITIONAL_DETAILS'); ?>
                                </th>
                        </tr>
                        <?php foreach ($this->K2Plugins as $K2Plugin): ?>
                        <?php if(!is_null($K2Plugin)): ?>
                        <tr>
                                <td colspan="2">
                                        <?php echo $K2Plugin->fields; ?>
                                </td>
                        </tr>
                        <?php endif; ?>
                        <?php endforeach; ?>
                        <?php endif; ?>
                        
                        <!-- Joomla! 1.6+ JForm implementation -->
                        <?php if(isset($this->form)): ?>
                        <?php foreach ($this->form->getFieldsets() as $fieldset): // Iterate through the form fieldsets and display each one.?>
                                <?php if($fieldset->name != 'default'): ?>
                                <?php $fields = $this->form->getFieldset($fieldset->name);?>
                                <?php if (count($fields)):?>
                                        <?php if (isset($fieldset->label)):// If the fieldset has a label set, display it as the legend.?>
                                        <tr>
                                                <th colspan="2" class="k2ProfileHeading">
                                                        <?php echo JText::_($fieldset->label);?>
                                                </th>
                                        </tr>
                                        <?php endif;?>
                                        <?php foreach($fields as $field):// Iterate through the fields in the set and display them.?>
                                                <?php if ($field->hidden):// If the field is hidden, just display the input.?>
                                                        <tr><td colspan="2"><?php echo $field->input;?></td></tr>
                                                <?php else:?>
                                                        <tr>
                                                                <td class="key">
                                                                        <?php echo $field->label; ?>
                                                                        <?php if (!$field->required && $field->type != 'Spacer'): ?>
                                                                                <span class="optional"><?php echo JText::_('COM_USERS_OPTIONAL');?></span>
                                                                        <?php endif; ?>
                                                                </td>
                                                                <td><?php echo $field->input;?></td>
                                                        </tr>
                                                <?php endif;?>
                                        <?php endforeach;?>
                                <?php endif;?>
                                <?php endif; ?>
                        <?php endforeach;?>
                        <?php endif; ?>
                <?php 
if (!($this->K2Params->get('recaptchaOnRegistration') && $this->K2Params->get('recaptcha_public_key'))) { 
$configured_captcha = JFactory::getApplication()->getParams()->get('captcha', JFactory::getConfig()->get('captcha')); 
if (!empty($configured_captcha)) { 
$jcaptcha = JCaptcha::getInstance($configured_captcha, array('namespace' => 'com_users.registration')); 
if (!is_null($jcaptcha)) { 
JRequest::setVar('session_secret', uniqid()); // Required by playthru captcha plugin 
$ccode = $jcaptcha->display("jcaptcha", "jcaptcha", "required"); 
echo '<tr>' . "\n"; 
echo '<td class="key">' . JText::_('TPL_BOS_PLAYTHRU_CAPTCHA_LABEL') . "</td>\n"; 
echo "<td>" . $ccode . "</td>\n"; 
echo "<td> * </td>\n"; 
echo '</tr>' . "\n"; 
} 
} 
} 
?>   
                </table>
                                <?php if($this->K2Params->get('recaptchaOnRegistration') && $this->K2Params->get('recaptcha_public_key')): ?>
                <label class="formRecaptcha"><?php echo JText::_('K2_ENTER_THE_TWO_WORDS_YOU_SEE_BELOW'); ?></label>
                <div id="recaptcha"></div>
                <?php endif; ?>           
                <div class="k2AccountPageNotice"><?php echo JText::_('K2_REGISTER_REQUIRED'); ?></div>
                <div class="k2AccountPageUpdate">
                        <button class="button validate" type="submit">
                                <?php echo JText::_('K2_REGISTER'); ?>
                        </button>
                </div>
        </div>
        <input type="hidden" name="option" value="<?php echo $this->optionValue; ?>" />
        <input type="hidden" name="task" value="<?php echo $this->taskValue; ?>" />
        <input type="hidden" name="id" value="0" />
        <input type="hidden" name="gid" value="0" />
        <input type="hidden" name="K2UserForm" value="1" />
        <?php echo JHTML::_( 'form.token' ); ?>
</form>

Thanks Michael!

One final thing - would this bit of code be useable in the item comments template too? The K2 recaptcha being over-ridden by playthru captcha and ecalc would be excellent

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

More
10 years 1 month ago #114396 by Jacqueline
Replied by Jacqueline on topic Re: [HOW TO]: Captcha other than recaptcha
Hello,

Followed your instructions and cant get seem to work.. also checked installation from portal.areyouahuman.com/installation/joomla

no display of captcha..

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

More
10 years 1 month ago #114397 by JoomlaWorks
Replied by JoomlaWorks on topic Re: [HOW TO]: Captcha other than recaptcha
I would recommend using Akismet which is already built into K2. Get a free API key from akismet.com for your site and simply paste back this key into K2's parameters. No captcha to show, uses one of the best antispam services worldwide.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum