Captcha shown twice when core "User Profile" plugin is enabled

12 years 7 months ago #6563 by plamendp
Subjects says it all, but here are some clarification.

When I enable the Joomla core "User Profile" plugin, all profile fields are correctly displayed (registration page), but the Captcha (and Question and Re-Captcha for that matter) are displayed TWICE (See attached picture).

I found the reason why it happens, but need someone to confirm my solution.

File:
components/com_ajaxregister/views/registration/tmpl/default.php

Line: ~125 .. 156
This code block checks if question/captcha/re-captcha is enabled and acts accordingly, i.e. display captcha, for example.  The problem is that this code block is INSIDE the foreach() loop which iterates all available fieldsets (account + profile, in case Profile plugin is enabled). This way it shows captcha for BOTH fieldsets: account AND profile.

Solution:
Move this code block outside foreach() loop:

<?php foreach ($this->form->getFieldsets() as $fieldset): // Iterate through the form fieldsets and display each one.?>
<?php $fields = $this->form->getFieldset($fieldset->name);?>
<?php if (count($fields)):?>
<fieldset>
<?php if (isset($fieldset->label)):// If the fieldset has a label set, display it as the legend.?>
<!--<legend><?php //echo JText::_($fieldset->label);?></legend>-->
<?php endif;?>
<dl>
<?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.?>
<?php echo $field->input;?>
<?php else:?>
<dt>
<?php echo $field->label; ?>
<?php if (!$field->required && (!$field->type == "spacer")): ?>
<span class="optional"><?php echo JText::_('COM_USERS_OPTIONAL');?></span>
<?php endif; ?>
</dt>
<dd><?php echo $field->input;
// password strength
if ($field->id=='jform_password1' && $this->password_strength) {
?>
<div class="ar_password_strength">
<div class="ar_password_bar_container">
<div id="jform_password1_bar" class="ar_password_bar"></div>
</div>
<div id="jform_password1_text" class="ar_password_text"></div>
</div>
<?php
}
?></dd>
<?php endif;?>
<?php endforeach;?>

<!-- CODE BLOCK WAS HERE --- MOVED OUTSIDE  -->

</dl>
</fieldset>
<?php endif;?>
<?php endforeach;?>


<!-- CODE BLOCK: BEGIN -->
<fieldset>
  <dl>       
<?php if (!empty($this->question)): ?>
<dt>
<label id="answermsg" for="answer">
<?php echo $this->question; ?>
<span class="star"> *</span>
</label>
</dt>
<dd>
<input type="text" id="answer" name="answer_<?php echo $this->question; ?>" class="required" size="40" />
</dd>
<?php elseif (!empty($this->recaptcha)): ?>
<dt class="captcha">
<script>
var RecaptchaOptions = {
  theme : '<?php echo $this->recaptcha_theme; ?>',
  lang : '<?php echo $this->recaptcha_lang; ?>'
};
</script>
<?php echo $this->recaptcha; ?>
</dt>
<?php elseif (!empty($this->captcha)): ?>
<dt class="captcha">
<label id="captcha-lbl" for="captcha">
<img src="<?php echo $this->baseurl; ?>/tmp/<?php echo $this->captcha;?>" alt="" id="captcha_img" />
<span class="star"> *</span>
</label>
</dt>
<dd>
<input type="text" id="captcha" name="<?php echo $this->captcha; ?>" class="required" size="10" />
<?php echo JText::_('AJAXREG_CAPTCHA'); ?>
</dd>
<?php endif;?>
    </dl>
</fieldset>

<!-- CODE BLOCK: END -->



Now, this solution WORKS for me (tested), but still I'd like authors to confirm it IS legitimate solution and does not break something else.

Thank you!



Plamen Petkov

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

12 years 7 months ago #6565 by Saka
Hi,

It has been fixed now (v1.8.3). Sorry for delay.

Thanks.

Emir Sakic
www.sakic.net

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

About us

We provide high quality Joomla components created by a co-founder and original core developer of Joomla. For over a decade, our products have been used by more than 20.000 webmasters around the world.

Stay in touch