0

I am trying to add the captcha core/text_list block to the wishlist_index_share handle in the wishlist.xml layout file but the block is not displayed.

Here is my code:

<wishlist_index_share translate="label">
   <label>Customer My Account Wishlist Sharing Form</label>
   <!-- Mage_Wishlist -->
   <update handle="customer_account" />
   <reference name="my.account.wrapper">
      <block type="wishlist/customer_sharing" name="wishlist.sharing" template="wishlist/sharing.phtml"/>
      <block type="core/text_list" name="form.additional.info">
         <block type="captcha/captcha" name="captcha">
            <reference name="head">
               <action method="addJs"><file>mage/captcha.js</file></action>
            </reference>
            <action method="setFormId"><formId>user_create</formId></action>
            <action method="setImgWidth"><width>230</width></action>
            <action method="setImgHeight"><width>50</width></action>
         </block>
      </block>
   </reference>
   <reference name="right">
      <action method="unsetChild">
         <name>wishlist_customer_sidebar</name>
      </action>
   </reference>
</wishlist_index_share>

I also added to Mage/captcha/etc config.xml to the frontend areas the following so the form would show up in the System -> configuration -> customer configuration -> captcha section form list:

<wishlist_index_share>
   <label>Share Wishlist</label>
</wishlist_index_share>

Also in the same file, in customer -> captcha:

<always_for>
   <user_create>1</user_create>
   <user_forgotpassword>1</user_forgotpassword>
   <guest_checkout>1</guest_checkout>
   <register_during_checkout>1</register_during_checkout>
   <wishlist_index_share>1</wishlist_index_share>
</always_for>

In the wishlist.phtml file I call the captcha block with the following line:

<?php echo $this->getChildHtml('form.additional.info'); ?>

Any ideas of what I need to add to the layout file? Thank you so much

1 Answer 1

0

CAPTCHA support has been added to the wishlist share since 1.9.4.0 and the SUPEE-10975 patch that were both released on 28-11-2018.

When I compare the above changes to the changes introduced in the new version of Magento, I see three differences:

  1. The changes to Mage_Captcha_Model_Zend::isRequired are missing, which make sure the CAPTCHA is always shown for the wishlist share and sendfriend form.

  2. the CAPTCHA block (form.additional.info) is added as a child of my.account.wrapper, not as a child of wishlist.sharing.

  3. Backend validation is missing, which is done via an observer on the controller_action_predispatch_wishlist_index_send event.

Hope this helps.

6
  • Thank you so much for answering, I changed the code similar to your comments. I can't share it here bc I have limited characters. I added this: <controller_action_predispatch_wishlist_index_send> with the method: checkShareWishlist to Mage/Captcha/etc/config.xml Then added the <wishlist_index_share> with the captcha code inside to local.xml Then added the following method to the observer: public function checkShareWishlist($observer) { } Captcha not displayed on form with email and message but when wishlist shared, the incorrect captcha in the form is displayed. SOS please Commented Dec 12, 2018 at 22:40
  • Also, I placed the Observer.php file, that I updated to have the form I need the captcha in, in app/code/local/Mage/Captcha/Model/Observer.php. Should I place it in local/Captcha/Model/Observer.php ??? Thank you so much! Commented Dec 13, 2018 at 14:46
  • 1
    I'm afraid I can't really help you much further with the above issues as I haven't use the old Mage_Captcha module myself in years. However, why don't you install the SUPEE-10975 patch? This update that adds all of the above changes (and addresses other security issues). I also suggest to use a module that adds a more user friendly CAPTCHA than Zend_Captcha. I have achieved good results using the ProxiBlue_ReCaptcha module; this module extends the Mage_Captcha module, and allows for integrating Google reCAPTCHA v2, including Invisible reCAPTCHA. Commented Dec 13, 2018 at 20:41
  • Thank you so much for your time! I will take a look at the patch and also to the new captcha. Thank you so much again. Commented Dec 17, 2018 at 18:04
  • Aad! I learned a bit more about the handles, I fixed the wishlist_index_share reference name in my local.xml file, also added the Observer.php code to validate the captcha, I am using the correct form name which is the one you use in your module config.xml file (default/captcha/frontend/areas/wishlist_captcha/label). Also I made sure that the handle was loaded by using: Zend_Debug::dump($this->getLayout()->getUpdate()->getHandles()); I still do not see the captcha on the form. Any ideas why? I am using magento 1.9.2.4 Thanks! Commented Mar 5, 2019 at 18:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.