Posted by G.S on May 20, 2010 at 2:09pm
11 followers
Jump to:
| Project: | CAPTCHA |
| Version: | 7.x-1.0-beta2 |
| Component: | Miscellaneous |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
This is probably a duplicate but I can't for the life of me find it. When I add any Captcha (Image or Math) to a webform with multiple pages, it appears on every page whereas I'd like it to appear only on the last page, when the user submits the form.
I wasn't sure to put this as a bug report or feature request but regardless, any help would be appreciated.
Comments
#1
No, this isn't a duplicate, nor it is currently possible.
So this makes it a feature request.
#2
Funny how sometimes people seem to try and do exactly the same thing at exactly the same time... I couldn't figure this out as well and now I know why. I'd love this feature!
#3
Me too: feature request please!
#4
argh, yes! need this one please. using recaptcha, it appears on the front page rather than the last.
are there any workarounds or non-captcha solutions to this?
thanks
#5
Subscribing.
#6
I'm also looking for this feature
#7
I'm using the re-captcha and need this as well. I'll offer to help out if and when I can, but similar to yourself I am finding that spare time is in the minority at the moment. I'll see if I can persuade a client to sponsor development of this.
At the moment I have had to resort to manually adding the recaptcha to the forms.
http://www.google.com/recaptcha
I use this on all other forms on the site so its not an ideal solution.
#8
I adapted a solution i found for mollon.
Using reCaptcha and the captcha module resulted in having the captcha on every page of a multi page webform.
I use the following in a module to disable it on all but the last page.
<?phpfunction webform_captcha_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'webform_client_form_node-id':
$page_num = $form['details']['page_num']['#value'];
$page_count = $form['details']['page_count']['#value'];
if ($page_num != $page_count) {
unset($form['actions']['captcha']);
}
break;
}
}
?>
#9
In which module did you put this code?
<?phpfunction webform_captcha_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'webform_client_form_node-id':
$page_num = $form['details']['page_num']['#value'];
$page_count = $form['details']['page_count']['#value'];
if ($page_num != $page_count) {
unset($form['actions']['captcha']);
}
break;
}
}
?>
#10
This isn't a workaround for Drupal. What should be the syntax in D7?
#11
Here is the proper code for D7:
<?phpfunction mymodule_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'webform_client_form_form-id':
$page_num = $form['details']['page_num']['#value'];
$page_count = $form['details']['page_count']['#value'];
if ($page_num != $page_count) {
unset($form['captcha']);
}
break;
}
}
?>
#12
Something to take note, when I tried #8 solution is that your custom module must be executed after the Captcha module.
In my part, I had to set the module weight of my custom module (in the system table) higher than that of the Captcha module (this is usually set to 0 by default).
#13
Here is an easy solution for Drupal 7 and Captcha version [captcha-7.x-1.0-beta2.zip]:
You need to modify two functions in captcha módule file: captcha.module
The first function is:
/**
* Process callback for CAPTCHA form element.
*/
function captcha_element_process($element, &$form_state, $complete_form) {
$page_count = $form_state['webform']['page_count']; /*** MODIFICACION: ADD****/
$page_num = $form_state['webform']['page_num']; /*** MODIFICACION: ADD****/
if ($page_num == $page_count){ /*** MODIFICACION: ADD****/
//... Original function code here...
} /*** MODIFICACION: ADD ***/
return $element;
}
The second function is:
/**
* CAPTCHA validation handler.
*
* This function is placed in the main captcha.module file to make sure that
* it is available (even for cached forms, which don't fire
* captcha_form_alter(), and subsequently don't include additional include
* files).
*/
function captcha_validate($element, &$form_state) {
$page_count = $form_state['webform']['page_count']; /* MODIFCACION: ADD ***************/
$page_num = $form_state['webform']['page_num']; /* MODIFCACION: ADD ***************/
if ($page_num == $page_count){ /* MODIFCACION: ADD ***************/
//... Original function code here...
} /** MODIFICACION: ADD ******************/
}
I hope this solution help you :)