Update the functions file for reCaptcha.
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 10 Oct 2017 16:58:45 +0000 (12:58 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 10 Oct 2017 16:58:45 +0000 (12:58 -0400)
Save captcha in session. This will allow someone to have submit errors
then be able to pass the reCaptcha test next time they submit.

functions.php
style.css

index 2392978..4935ba2 100755 (executable)
@@ -314,4 +314,30 @@ function custom_wc_checkout_fields( $fields ) {
 }
 add_filter( 'woocommerce_checkout_fields' , 'custom_wc_checkout_fields' );
 
+
+// Dissable captch if it has been solved once using session
+// safely start a session
+function my_session_start( ) {
+       $sid = session_id();
+       if ( empty( $sid ) ) {
+               session_start();
+       }
+}
+add_action('init','my_session_start',1);
+
+// don't requiere captcha, if session says so
+function my_wp_recaptcha_required( $is_required ) {
+       if ( isset( $_SESSION['recaptcha_solved'] ) && $_SESSION['recaptcha_solved'] )
+               return false;
+       return $is_required;
+}
+add_filter('wp_recaptcha_required' , 'my_wp_recaptcha_required');
+
+// store in session if captcha solved
+function my_wp_recaptcha_checked( $check_successful ) {
+       if ( $check_successful )
+               $_SESSION['recaptcha_solved'] = true;
+}
+add_action('wp_recaptcha_checked','my_wp_recaptcha_checked');
+
 ?>
index 89eea28..cbc8f17 100755 (executable)
--- a/style.css
+++ b/style.css
@@ -3,5 +3,5 @@ Theme Name: Tom's Mom's Cookies
 Author: Gaslight Media
 Author URI: http://www.gaslightmedia.com
 Description: A theme made for Tom's Mom's Cookies.
-Version: 1.0.20
+Version: 1.0.21
 */