Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm looking to add captcha support to the webform module, but it doesn't look like there's any easy way to append items to the list of captcha_points (other than editing the module source!).
Could a hook be added into captcha to append other module forms? Something like this in the captcha module:
$newpoints = module_invoke_all("captcha_add");
foreach ($newpoints as $key=>$value) {
$captcha_points[$key] = $value
}
And then in the any other module (such as webform, for instance) put:
function webform_captcha_add () {
return array (
'webform_client' => t('Webform Client Form'),
'webform_someotherform' => t('Some Other Webform Form'),
);
}
I'm looking forward to adding this much requested feature to webform, thanks!
Comments
Comment #1
quicksketchComment #2
kulvik CreditAttribution: kulvik commentedI'd also like something like this. I really need to use captcha with my guestbook module. It fille up with spam daily :/
Comment #3
quicksketchHere's a bit of a work-around for this issue. I've found that more of a change would be necessary than I originally thought. What if a module wanted to customize the captcha, rather than having the captcha module simply stick the captcha at the bottom of the form? A seperate function would be needed that would return only the captcha and skips all the form-specific code currently in the captcha_form_alter() function.
In the exisiting system, we can still accomplish what we want by copying some of the captcha code into the custom module and passing in a fake form item to the captcha module, then merging the result with our custom module form. That sounds more complicated than it is. Here's the code:
Comment #4
arnabdotorg CreditAttribution: arnabdotorg commentedThe concept of a "captcha point" exists in the cvs version, which uses an array to define what forms you want to use captcha for. One option is to have a "captchapoint" hook, in which every module returns what all points you could have captchas. this is added to the list of captcha points, and this will show up in the captcha config.
Comment #5
arnabdotorg CreditAttribution: arnabdotorg commentedugh, i just noticed the original post says more or less the same thing i wrote. i should go sleep now.
Comment #6
wundo CreditAttribution: wundo commentedThis is a Great feature, I will work in it today... Then I post my solutions here to see what you think ;)
Comment #7
kowalke CreditAttribution: kowalke commentedI don't suppose there could be a patch for this that one could apply to a 4.6 install? I'm not quite able to upgrade to 4.7 yet, but I desperately need captcha on my feedback form (which I hear isn't a problem with 4.7).
Comment #8
wundo CreditAttribution: wundo commentedComment #9
donquixote CreditAttribution: donquixote commentedThis doesn't appear to be fixed .. or otherwise, it needs some documentation.
+1 for this feature request!
In particular, I would like to automatically integrate with webform.
Comment #10
soxofaan CreditAttribution: soxofaan commented@donquixote
This is a bit of an old/outdated thread, so this might not be the best place to discuss this (e.g. strange thing in #1: the version was changed from 4.6.x-1.x-dev to 6.x-2.x-dev, but I doubt that even Drupal 6 existed in 2006)
Anyway, this might be the function you are looking for (first function in captcha.inc):
Setting this thread back to fixed, unless someone disagrees :)
Comment #11
donquixote CreditAttribution: donquixote commentedThe point is that I would like to be a bit more independent of the form id.
Webform form ids depend on the node id, and I really don't like code that depends on node ids.
I am looking for something that can be called in hook_form_alter, or in a form builder function. Or maybe even a #process handler that can be attached to the form.
I am sure one could come up with more ideas..
If you know a better place to discuss this, let me know!
Comment #12
soxofaan CreditAttribution: soxofaan commentedok, then you are probably interested in this part of #641122: Integrate with Spam module:
But true, this should be documented better
Comment #13
soxofaan CreditAttribution: soxofaan commentedMade a new issue about this: #743056: Document how to add a CAPTCHA programmatically
I think it's best to continue the discussion over there, and close this issue again because it's mainly from the Drupal 4.7 era.