When using ubercart with the anonymous checkout option it does this call:

  drupal_execute('user_login', $form_state);

Since they do not pass the answer to the captcha question through the login fails.

A possible solution would be to add to the captcha_validate() function a check for some sort of override.
For example, maybe do (just a suggestion, not an actual solution):

<?php
  if ($form_state['override_captcha_check']) {
    // Skip the answer check or populate answer field with correct answer and continue.
  }
?>

Then, whenever a captcha form is called programmatically this value can be passed through in the form state.

Comments

agileware’s picture

Actually to be more specific, it fails because 'SELECT solution FROM {captcha_sessions} WHERE csid = %d AND status = %d'
doesn't return because csid is NULL because there is no clicked button in $form_state.

This means it can't be overridden by ubercart adding it's own $element['#captcha_validate'] function.

agileware’s picture

For reference this is the error you get:

CAPTCHA validation error: unknown CAPTCHA session ID. Contact the site administrator if this problem persists.

agileware’s picture

I have also started an issue for ubercart regarding this.
See #701912: Anonymous checkout doesn't work with captcha enabled on the user login form

Maybe it could be better solved by them changing their login process.

soxofaan’s picture

Another possible solution is maybe to create a small glue module that removes the CAPTCHA form element in hook_form_alter when doing the anonymous checkout

function ubercar_anonymous_checkout_captcha_fixer_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'user_login' && this_is_anonymous_checkout) {
    unset($form['captcha']);
  }
}
agileware’s picture

Status: Active » Fixed

Yeah, that kind of solution would probably be best as it doesn't involve changing either of the modules core functionality.

That's something that should be done on the ubercart end so I'll close this one.

Thanks for the suggestion.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

metajunkie’s picture

Where can I find this being followed up? Is there a link to a new thread? Is it on this site, or the Ubercart site? I still have this issue.

agileware’s picture

@metajunkie:

You should probably read the whole issue, it's not very long.

The link to the ubercart issue is in comment #3.