form IDs for my entity forms is not listed in the catchpa general settings.
Can anyone explain how I add the catchpa?
4 Answers
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
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
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):
After enabling the Captcha module go to
admin/config/people/captcha
and add the node article form id and save the configuration.Go to node article form and you can see the captcha(for non admin)
Note:
- Configure the captcha setting as per your requirement.
To add a CAPTCHA to an Entityform Type in Drupal:
Install or enable the contributed Captcha module.
Determine which Entityform Type(s) you want a CAPTCHA added to:
Admin > Structure > Entityform Types
admin/structure/entityform_types
From the list of Entityform Types, copy the Machine Name of the Entityform Type (e.g.
contact_us
).Configure the Captcha module:
Admin > Configuration > People > CAPTCHA
admin/config/people/captcha
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 becontact_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.
Select the appropriate Challenge Type or use the defaults.
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.
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
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.