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')....

CommentFileSizeAuthor
#4 Captchapoint API.pdf15.7 KBdavemybes
#1 hook_captchapoint.patch2.73 KBjoshk

Comments

joshk’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new2.73 KB

...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

davemybes’s picture

Sheer genius!! This works perfectly in Drupal 4.7.4 with the SimpleInvite Module (http://drupal.org/project/simpleinvite).

Great job.

joshk’s picture

Title: Adding Captcha Points » Adding Captcha Points

Thanks! Hopefully this will get rolled in 5.0... Maybe we should also write a little documentation for developers.

davemybes’s picture

StatusFileSize
new15.7 KB

joshk, here is some documentation for the captchapoint API. Let me know if its acceptable.

joshk’s picture

Looks awesome!

somebodysysop’s picture

Will this work with flexinode? If so, how is this code created?

function hook_captchapoint() {
return array('my_form_id', 'my_other_form_id');
}

I *think* the flexinode form creation function is:

/**
 * Implementation of hook_form().
 */
function flexinode_form(&$node, &$param) {

but, don't know enough about it to be sure.

So, my un-educated guess is:

function flexinode_captchapoint() {
return array(flexinode_form, 'Flexinode Creation');
}

Can someone please give me some guidance here? Thanks.

-ron

somebodysysop’s picture

I'm sorry, this is the code I've tried for flexiinode but doesn't work:

 function flexinode_captchapoint() {
 return array('flexinode_form' => t('Flexinode Creation Form'));
}
davemybes’s picture

Never tried it with flexinode, but maybe this code will work:

function flexinode_captchapoint() {
return array('flexinode_form');
}
colan’s picture

I'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.

davemybes’s picture

Actially, 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.

mstef’s picture

OK, 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

heine’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

Please 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).