It would be really great if there were a way for module-makers to somehow register their captcha points with captcha.module. For instance, I wanted to do this w/forward.module, and just hacked captcha_settings to include an array item for 'forward_form' in $captcha_points and it worked like a charm.
Maybe an ultra-light API, like "hook_captchapoint" which can add add form_ids to the $captcha_points?
function hook_captchapoint() {
return array('my_form_id', 'my_other_form_id');
}
This would be easy to pick up in captcha_settings with a module_invoke_all('captchapoint')....
Comments
Comment #1
joshk commented...so easy I rolled a patch. This works. It has captcha.module implement hooks for the core form_ids, and it's easy as pie for other modules to register their own captcha points. Tested with 4.7.3
Comment #2
davemybes commentedSheer genius!! This works perfectly in Drupal 4.7.4 with the SimpleInvite Module (http://drupal.org/project/simpleinvite).
Great job.
Comment #3
joshk commentedThanks! Hopefully this will get rolled in 5.0... Maybe we should also write a little documentation for developers.
Comment #4
davemybes commentedjoshk, here is some documentation for the captchapoint API. Let me know if its acceptable.
Comment #5
joshk commentedLooks awesome!
Comment #6
somebodysysop commentedWill this work with flexinode? If so, how is this code created?
I *think* the flexinode form creation function is:
but, don't know enough about it to be sure.
So, my un-educated guess is:
Can someone please give me some guidance here? Thanks.
-ron
Comment #7
somebodysysop commentedI'm sorry, this is the code I've tried for flexiinode but doesn't work:
Comment #8
davemybes commentedNever tried it with flexinode, but maybe this code will work:
Comment #9
colanI'm trying to do this stuff with Signup, but the captcha validation is appearing outside of the collapsed fieldset containing the submit button and all, making the page look rather awkward. I played around with it for a while trying to come up with a clever hack, but then thought it would make more sense to incorporate a way of doing this into the "Adding captcha points" functionality.
So, what about providing an optional parameter that contains the name of the fieldset if that's where the actual form functionality lies? If it's there, then Captcha would know how to insert itself into that subform.
Comment #10
davemybes commentedActially, your best option there is to create your own site-specific module that implements a hook_form_alter. In that function, simply check for the Captcha form and move it into the correct fieldset. Putting this as an option in the module is probably not going to happen. Most people won't be able to know the name of the fieldset anyway.
Comment #11
mstef commentedOK, a few things..
1) I didn't need this patch to get forward to work with captcha. Alls you have to do is add forward_node to $captcha_points = array() in the beginning of captcha.module
2) What exactly does this patch do, and how do you use it exactly?
3) How can I get privatemsg to work with captcha. I have opened another thread for this because this one didnt seem to make any sense at all to me at first. I tried adding privatemsg_message_form to captcha the same way I did with forward_node but you get a handful of mysql errors, not sure why. How can I do this????
Thanks
Comment #12
heine commentedPlease do not set your own patch to RTBC.
Marking duplicate of http://drupal.org/node/125588 (needs backporting).
@mikestefff, please open new issues (one per problem).