Magento – How to add captcha in product review form in magento2

captchamagento2

I am trying to add Captcha inside product review form. For that i add

<referenceContainer name="form.additional.info">
            <block class="Magento\Captcha\Block\Captcha" name="captcha" after="-" cacheable="false">
                <action method="setFormId">
                    <argument name="formId" xsi:type="string">user_login</argument>
                </action>
                <action method="setImgWidth">
                    <argument name="width" xsi:type="string">230</argument>
                </action>
                <action method="setImgHeight">
                    <argument name="width" xsi:type="string">50</argument>
                </action>
            </block>
        </referenceContainer>
        <referenceBlock name="head.components">
            <block class="Magento\Framework\View\Element\Js\Components" name="captcha_page_head_components" template="Magento_Captcha::js/components.phtml"/>
        </referenceBlock>

in theme/Magento_Review/layout/catalog_product_view.xml file. and after that i am calling it in /theme/Magento_review/template/form.phtml file like

<?php echo $block->getLayout()->getBlock('form.additional.info')->toHtml(); ?> But after that no captcha is showing in the review form. Please help me to do it. Thanks

Best Answer

To use google reCaptch : Go to Admin -> Store -> Configuration -> Security Tab -> Google reCaptcha -> Frontend -> Enabled = Yes

Use in Review = select Yes

Add getChildHtml('form.additional.info') ?> in your theme's Magento_Review /templates/form.phtml file.