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.
If the Captcha module is implemented on a multi-page Webform form, a captcha is added to each page. Is there anyway to set it up to only add a captcha to the last page of a form before submit?
Comments
Comment #1
tcheard CreditAttribution: tcheard commentedThis same issue also occurs with the Mollom module.
Is there any way around this?
Comment #2
TimelessDomain CreditAttribution: TimelessDomain commentedthis is important - since many multipage webforms have the first page very clean (to trick users into thinking that they are filling out a very simple form), having the captcha not appear on the first page is ideal. Last page would be ideal.
Comment #3
quicksketchMoving this to a feature request. I think it sounds like a great idea but I'm not sure if it's possible to implement with the way Mollom and CAPTCHA module currently function.
Comment #4
tcheard CreditAttribution: tcheard commentedSo should this be more directed at Mollom/CAPTCHA?
Comment #5
quicksketchI'd like to say that Mollom/CAPTCHA would be the correct place, but we'd probably need to implement something on the Webform side to inform Mollom/CAPTCHA when we were on the last page of the form.
To make things even crazier, if you have conditional page logic, the last page of the form might actually be skipped under some conditions, so it's hard to say what the "last page" really is if you're sometimes skipping certain pages.
For the time being I think this is best kept in the Webform queue until we check if there is already a mechanism we can use in one or both of these modules. If more information can be provided on doing this from one of the other modules that would also be great, but for the most part I expect Webform is going to be the the party responsible for implementation.
Comment #6
quicksketchLet's merge this with #768872: Provide direct Mollom and CAPTCHA module support to allow authors to enable instead of administrators.
Comment #7
widukind CreditAttribution: widukind commentedMy workaround is to modify my multistep webform in my module's
hook_form_alter()
implementation. For any but the last step of the form, I remove all Mollom-related submit/validate handler configurations and the Mollom object itself from the form.A look into
mollom_form_alter()
gave all the answers on what needs to be taken out.I found this to be working nicely with Webform 6.x.-3.11, Mollom 6.x-3.11 and Drupal 6.22.
CAVEAT: Ensure that your module is loaded and run after Mollom, e.g. by bumping up your module's weight in the "system" table.
Comment #8
allio_froggio CreditAttribution: allio_froggio commentedIs there any chance that a captcha can be added as a type of field? This would give the user the ability to define when/if to show a captcha and would avoid the difficulty of figuring out what the last page is.
I'm sure there's a technical reason why this is difficult/can't be done but I thought I would throw the idea out there.
Comment #9
Akshita CreditAttribution: Akshita commentedIf the Captcha module is implemented on a multi-page Webform form, a captcha is added to each page. Is there anyway to set it up to only add a captcha to the last page of a form before submit?
Please help how to resolve this issue.
Comment #10
vernond CreditAttribution: vernond commentedPlease do not cross post or re-open old issues. We already have your issue at http://drupal.org/node/1559498
Comment #11
seismicmike CreditAttribution: seismicmike commentedWith respect, this is not a duplicate issue. http://drupal.org/node/1559498 is concerned with only showing the CAPTCHA on the first page and then not showing it on subsequent pages after it has been completed. This issue, and the one I am very interested in addressing, is concerned with only showing the CAPTCHA on the last page. The solution provided for http://drupal.org/node/1559498 does not address the concern of this issue. Please reconsider.
Thank you.
Comment #12
seismicmike CreditAttribution: seismicmike commentedI think I remember looking into a similar problem a while back and it has to do with the CAPTCHA module looking for submit buttons and prepending itself to them. Thus, when it finds the "Next" and "Previous" buttons, it prepends to them. I never found a solution for that.
This may indeed be a CAPTCHA issue and not a webform issue, but if there was a way to change the next and previous implementation so that the CAPTCHA would not identify them as "submit" buttons, then the issue would be taken care of. I fiddled with this a while back in an AHAH form in which I had a button that was supposed to do some AHAH magic and CAPTCHA prepended to it. I ended up giving up and ditching the CAPTCHA on that form. I'd have to look into the form API closer to see if there's a way to spoof this. If you're interested, I could try to take a look.
Comment #13
Abhinesh Sharma CreditAttribution: Abhinesh Sharma commentedHi AKshita,
In Drupal 7:-
First Solution is
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 ******************/
}
Second Solution is
Create your Custom Module and then use
I hope this solution help you :)
Thanks
Comment #14
Abhinesh Sharma CreditAttribution: Abhinesh Sharma commentedIt's Closed
Comment #15
Akshita CreditAttribution: Akshita commentedThank You Abhinesh.
Comment #16
AnybodyI can confirm that this feature request is still an issue and it would be cool if the captcha could be placed on the last page by default. I think that would be what most people need.
Comment #17
knalstaaf CreditAttribution: knalstaaf commentedI agree this issue was closed a little too soon. The solution in #13 may be useful, the situation is far from ideal. It puts the conversion rate at jeopardy in some cases (we had to disable Mollom altogether because of this).
Comment #18
DanChadwick CreditAttribution: DanChadwick commentedI don't think we will be special-casing for mollom or captcha code. These modules added their form element(s) to the webform. They can add them to the right page, rather than webform looking for other modules additions and removing them.
Also note that the last page is not guaranteed to be displayed to the user in conditionals hide it. In this case, the preview page is forced.