I'm using magento 2.2, I've enabled Admin-Panel -> Store -> Customers -> Customer Configuration -> CAPTCHA and enabled it for following forms: "Create user", "Login", "Forgot password".

The "Login" case: The captcha works well on default theme (LUMA theme).But when I'm using another theme, the Captcha image (or the Captcha form with message and image) is not showed up, and I'm ending up with "Incorrect CAPTCHA".

I tried to find any related forum thread about this, but I wasn't able to find something that is well described. I checked all file permissions and those are OK, I've checked magento logs no exception there.

My theme has the following structure: /app/code /app/design/frontend/Theme_name/some_name/

  • This contain (beside others folders and files like /etc and so on) a theme.xml file that point to the parent_theme folder /app/design/frontend/Theme_name/parent_theme

On the parent_theme I have the /parent_theme/Magento_Customer/layout - this contains "customer_account_login.xml" which is almost identical with the one from -> customer_account_login.xml and to what I have on Magento-CE-2.2.2-2017-12-11-09-19-32/vendor/magento/module-customer/view/frontend/layout/customer_account_login.xml

From what I could understand here will fill with the captcha form.

<container name="customer.login.container.before" htmlTag="div" htmlClass="col-sm-6 col-xs-12" before="-">
                    <block class="Magento\Customer\Block\Form\Login" name="customer_form_login" template="form/login.phtml">
                        <container name="form.additional.info" as="form_additional_info"/>

     parent_theme/Magento_Customer/layout/templates/form/login.phtml    - which is similar to [login.phtml][1]
  • In this file I have the getChildHtml('form_additional_info') ?>, only design is different.

I tried everything, I also overwrite those file with default one (from https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Customer/view/frontend/), design was changing but Captcha form wasn't showing up.

I tend to think that my theme is missing something, I read somewhere that captcha layout should be overwrite in order to make it visible but no detailed on how to do that.

Can someone who hit this problem, or has experience on making themes let me know what I'm missing?


3 Answers 3


I was facing the same issue before and in my case it was caused by my theme's customer_account_login.xml file.

For example, if your theme is extending Magento_Blank theme (which in most cases it probably is), then you don't need to copy the entire contents of the customer_account_login.xml file to your theme to make changes to it --> this will just "bug out" the CAPTCHA form.

The proper way to make changes is to use:

  • <block and <container> elements to add new elements (blocks or containers)
  • <referenceBlock>, <referenceContainer> to add new elements to existing ones, change their properties or just remove them
  • <move> to move existing elements in the layout

You can read instructions here on how to do that: http://devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/xml-instructions.html

If you are facing the same issue, you can quickly test it by renaming or removing your theme's customer_account_login.xml and clearing cache.

Then you can make the customizations the proper way based on the official documentation.

  • 1
    You were right. I just renamed the file from customer_account_login.xml to something else and this fixed my problem (It was exactly your scenario). Thank you, you made my day !
    – Mike
    Commented Feb 4, 2018 at 18:13
  • Thanks, this helped, in our case it was this line that break the captcha functionality: <container name="form.additional.info" as="form_additional_info"/>
    – SantiBM
    Commented Sep 20, 2019 at 12:04

Add the following captcha block into your customer_account_login.xml

        <block class="Magento\Captcha\Block\Captcha" name="captcha" after="-" cacheable="false">
            <action method="setFormId">
                <argument name="formId" xsi:type="string">user_login</argument>
            <action method="setImgWidth">
                <argument name="width" xsi:type="string">230</argument>
            <action method="setImgHeight">
                <argument name="width" xsi:type="string">50</argument>

Can someone be a little more specific on how to implement it exactly? I just want to add a

<meta name="robots" content="NOINDEX,NOFOLLOW"/>

to the head section of my customer login page. But when I override the complete file customer_account_login.xml, it adds my meta tag alright, but stops displaying recaptcha. I'm not sure how and where to use <referenceBlock>. Is the above file overriden with just a small piece of code, if yes, then how? Would appreciate a detailed answer. Thanks.

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.