• Resolved Brian P

    (@bburgay)


    Hi,

    I came across a couple issues with the plugin.

    1. When testing locally without an ssl certificate reCaptcha fails:

    error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in ....\wp-content\plugins\constant-contact-forms\vendor\recaptcha\src\ReCaptcha\RequestMethod\Post.php on line 68

    This is because with allow_url_fopen enabled the request method is not set to CurlPost. To fix it I removed the if block in class-process-form.php line 217:

    
    // if ( ! ini_get( 'allow_url_fopen' ) ) {  // <--- Commented Out
       $method = new \ReCaptcha\RequestMethod\CurlPost();
    // } // <--- Commented Out
    

    Is there any reason to not always use CurlPost to avoid errors?

    2. With ‘No page refresh’ enabled under ‘Submission behavior’ the custom ‘Success message’ under ‘Form Options’ is not displayed.

    This is because the ctct_process_form_success filter is not applied in the ajax process function process_form_ajax_wrapper. Here is the fix in class-process-form.php line 118:

    
    // $message = __( 'Your information has been submitted.', 'constant-contact-forms' ); // <--- Commented Out
    $form_id = $json_data['ctct-id']; // <--- Added
    $message = apply_filters( 'ctct_process_form_success', __( 'Your information has been submitted.', 'constant-contact-forms' ), $form_id ); // <--- Added
    

    -Brian

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Constant Contact

    (@constantcontact)

    Good morning @bburgay

    The reason why we added that conditional logic is because we had other users having issues with “invalid_json” errors coming from Google, and we deduced it was related to some of the issues outlined at https://stackoverflow.com/questions/30106668/nocaptcha-returning-error-invalid-json/30552041#30552041

    So, we check if file_get_contents() and its family of functions are available, and if not, then we fall back to cURL. The $method = null line right above that ini_get check should make it default to file_get_contents() in the long run, and we want the provided library from Google to use its chosen defaults when available.

    Curious if the information at https://stackoverflow.com/questions/6400300/https-and-ssl3-get-server-certificatecertificate-verify-failed-ca-is-ok could help with your local development issue at the moment.

    Good catch regarding the success message, we will get that filed as a bug and get that as part of a future release.

    Thread Starter Brian P

    (@bburgay)

    Hmmm… it seems odd that cURL would be causing invalid_json errors. It says right in the article https://stackoverflow.com/questions/30106668/nocaptcha-returning-error-invalid-json/30552041#30552041 – “Or you can use $recaptcha = new \ReCaptcha\ReCaptcha($secret, new \ReCaptcha\RequestMethod\CurlPost()); –> That always works.”

    Maybe there should be a check to see if cURL is available and use it if so? No big deal to me I can just comment out that code to get it to work but seems like it should really try to use cURL first.

    Plugin Author Constant Contact

    (@constantcontact)

    To clarify, it’s the file_get_contents() version, which is the default in the Recaptcha library, that was failing and causing the invalid_json errrors. The CurlPost()/cURL version is the fallback we’re using. It’s only getting specified and used if allow_url_fopen isn’t enabled for the given server.

    While not encountered yet, it is feasible that both could be not available on a given server, but as is, chances are great that we’ll succeed one way or another at the present moment.

    Thread Starter Brian P

    (@bburgay)

    Ok, I see. What I’m getting at though is why not use CurlPost as the default and the other as the fallback since cURL is so much more reliable and file_get_contents() caused the issue with invalid_json errors in the first place?

    Plugin Author Constant Contact

    (@constantcontact)

    If it becomes a bigger issue, we can definitely consider it, however since the change was released, we haven’t seen new issues come up yet. We’ll keep it in mind, for sure.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Failed Captcha & Custom Success Message’ is closed to new replies.