2

form IDs for my entity forms is not listed in the catchpa general settings.
Can anyone explain how I add the catchpa?

1
  • which module you are using to show captcha? – arpitr Nov 24 '13 at 22:01
7

Hope this will help you,

In Drupal 7 if you are using Captcha module, you can achieve it by the following steps

  • Let say you want to add Captcha to Article node form

    enter image description here

  • Get the node form for which you want to add the Captcha, you an achieve it by using

    
        //Implements hook_form_alter() for node_form().
        function hook_form_alter(&$form, &$form_state, $form_id) {
            //use drupal_set_message to print the form ID
            drupal_set_message("<pre>" . print_r($form_id,1) . "</pre>");
        }
    
  • After printing the node article form

    enter image description here

  • Get form id alternative (For developers) : Go on the page where your form is displayed. Next, use developer tools of your browser to show DOM structure. The form_id is displayed like the orange box on screenshot (Chrome example): enter image description here

  • After enabling the Captcha module go to admin/config/people/captcha and add the node article form id and save the configuration.

    enter image description here

  • Go to node article form and you can see the captcha(for non admin)

    enter image description here

Note:

  • Configure the captcha setting as per your requirement.
0
2

To add a CAPTCHA to an Entityform Type in Drupal:

  1. Install or enable the contributed Captcha module.

  2. Determine which Entityform Type(s) you want a CAPTCHA added to:

    Admin > Structure > Entityform Types
    admin/structure/entityform_types

  3. From the list of Entityform Types, copy the Machine Name of the Entityform Type (e.g. contact_us).

  4. Configure the Captcha module:

    Admin > Configuration > People > CAPTCHA
    admin/config/people/captcha

  5. Within the Form Protection fieldset, add the Machine Name* of the Entityform Type as the Form ID value.

    *Note: the Form ID expected by the Captcha module is the Entityform Type machine name appended with the string of text _entityform_edit_form.

    For instance, if your Entityform Type machine name is contact_us, the complete Form ID would be contact_us_entityform_edit_form.

    You can verify this by viewing the HTML source of an Entityform Type and cross-referencing the form's ID attribute:

    <form class="entityform" id="contact-us-entityform-edit-form" ...>

    Keep in mind, the actual value has hyphens replaced with underscores, as common in Drupal.

  6. Select the appropriate Challenge Type or use the defaults.

  7. Save the Captcha configuration changes.

To verify the CAPTCHA has been successfully added, open a private browsing session (e.g. a Chrome Incognito window) and view the Entityform Type, or simply view the form while logged-out of Drupal.

0

In the CAPTCHA config page the last in the list of form ID table will be an empty text box. You can enter the form ID of your entity form there, choose the type of challenge and save.

You need help finding the form id please find it in the answer here How to list all the form IDs

0

I know this kind of circumvents your original question, but I must discourage using a captcha at all; it is really a disservice to your users.

One great alternative is the Mollom module. It evaluates the contents of the form and only displays a captcha if it really looks like spam. It is quite accurate and a very easy installation - just go to Configuration > Mollom.

But my first step towards spam prevention (especially for smaller sites) is a homemade module that adds a few hidden 'honeypot' fields to a form. Humans can't see these fields so if they are non-empty, the form is assumed to be spam and is rejected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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