Captcha visible, but not validating
-
Hi there,
I use a woocommerce installation with a page where the user has to log-in or register before buying a product.
When I click the ‘register’ button without filling in the captcha, it gives me no warning or anything. It sends me to the next page.
<?php /** * Checkout Form * * This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-checkout.php. * * HOWEVER, on occasion WooCommerce will need to update template files and you * (the theme developer) will need to copy the new files to your theme to * maintain compatibility. We try to do this as little as possible, but it does * happen. When this occurs the version of the template file will be bumped and * the readme will list any important changes. * * @see https://docs.woocommerce.com/document/template-structure/ * @author WooThemes * @package WooCommerce/Templates * @version 2.3.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; } wc_print_notices(); foreach( WC()->cart->get_cart() as $cart_item ){ $product_id = $cart_item['product_id']; } $_SESSION['scrip_voice'] = $_REQUEST['scrip_voice']; $_SESSION['sound_design'] = (isset($_REQUEST['sound_design']) and $_REQUEST['sound_design']!='') ? "Yes" : "No"; $_SESSION['notes_voice'] = $_REQUEST['notes_voice']; $_SESSION['synchronize'] = (isset($_REQUEST['synchronize']) and $_REQUEST['synchronize']!='') ? "Yes" : "No"; //print_r($_SESSION); if(isset($_FILES['fileToUpload']) and $_FILES['fileToUpload']['tmp_name']!=''){ $order_id = mt_rand(1000000000,9999999999); $_SESSION['fakeorder'] = $order_id; if ( ! function_exists( 'wp_handle_upload' ) ) { require_once( ABSPATH . 'wp-admin/includes/file.php' ); } $upload_overrides = array( 'test_form' => false ); $movefile = wp_handle_upload($_FILES['fileToUpload'] , $upload_overrides); //print_r($_SESSION); $parent_post_id = $order_id; if ( !empty($movefile) ) { $wp_filetype = $movefile['type']; $filename = $movefile['file']; $wp_upload_dir = wp_upload_dir(); $wp_upload_dir['url']; /*$attachment = array( 'guid' => $wp_upload_dir['url'] . '/' . basename( $filename ), 'post_mime_type' => $wp_filetype, 'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)), 'post_content' => '', 'post_status' => 'inherit', 'post_parent' => $parent_post_id );*/ $attachment = array( 'guid' => $wp_upload_dir['url'], 'post_mime_type' => $wp_filetype, 'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)), 'post_content' => '', 'post_status' => 'inherit', 'post_parent' => $parent_post_id ); $attach_id = wp_insert_attachment( $attachment, $filename, $parent_post_id ); $_SESSION['attach_id'] = $attach_id; } } $uploadedfilevoice = $_FILES['fileToUpload']; $_SESSION['uploadedfile'] = $uploadedfilevoice; do_action( 'woocommerce_before_checkout_form', $checkout ); // If checkout registration is disabled and not logged in, the user cannot checkout if ( ! $checkout->is_registration_enabled() && $checkout->is_registration_required() && ! is_user_logged_in() ) { echo apply_filters( 'woocommerce_checkout_must_be_logged_in_message', __( 'You must be logged in to checkout.', 'woocommerce' ) ); return; } ?> <script> jQuery(document).on("mouseup", '.wc_payment_method', function(event){ if(event.target.nodeName == 'LABEL'){ jQuery( this ).trigger( 'update_checkout' ); } }); </script> <div class="single_product_wrap"> <div class="request_voice_wrapper"> <div class="single_product_request_voice new-req-voice checkout-main"> <div class="container"> <?php if (!is_user_logged_in()) { ?> <h1><?php echo nl("YI",get_locale(),"Your Information");?></h1> <?php $user = is_user_logged_in(); if ( is_user_logged_in()) { global $current_user; get_currentuserinfo(); echo nl("HU",get_locale(),"Hello User").", ". nl("YALIA",get_locale(),"You are logged in as") ." as ".$current_user->user_login."."; }else{ ?> <div class='woocommerce-additional-fields__field-wrapper ckout'> <div class='hundred'> <div class='fifty50'> <h1>Log-in</h1> <form name="loginform" id="loginform" action="<?php echo get_site_url(); ?>/wp-login.php" method="post" class=""> <p class="login-username"> <input type="text" name="log" id="user_login" class="input" value="" size="20" placeholder='<?php echo nl("UEA",get_locale(),"Username or Email Address") ?>'> </p> <p class="login-password"> <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" placeholder='<?php echo nl("PW",get_locale(),"Password") ?>'> </p> <a href="<?php echo wp_lostpassword_url( get_permalink() ); ?>" style="color: white;"><p>Wachtwoord vergeten?</a> <p class="login-submit"> <input type="submit" name="wp-submit" id="wp-submit" class="button product_type_simple add_to_cart_button ajax_add_to_cart added" value="<?php echo nl("LI",get_locale(),"Log In") ?>"> <input type="hidden" name="redirect_to" value="<?php echo get_site_url(); ?>/checkout/"> </p> </form> </div> <div class='fifty50'> <h1>Register</h1> <form action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post" id="custom-registration" > <p class="login-name"> <input type="text" name="user_login" placeholder="<?php echo nl("UN",get_locale(),"Username") ?>" id="user_login" class="input" required_/> </p> <p class="login-name"> <input type="text" name="user_firstname" placeholder="<?php echo nl("N",get_locale(),"Name") ?>" id="user_firstname" class="input" required_ /> </p> <!-- zelf toegevoegd <p class="login-lastname"> <input type="tel" name="user_lastname" placeholder="<?php echo nl("PN",get_locale(),"Last name") ?>" id="last_name" class="input" required_ /> </p> --> <!-- waarde wordt niet meegenomen <p class="login-phone_number"> <input type="tel" name="user_phone_number" placeholder="<?php echo nl("PN",get_locale(),"Phone Number") ?>" id="user_phone_number" class="input" required_ /> </p> --> <p class="login-email"> <input type="email" name="user_email" placeholder="<?php echo nl("E",get_locale(),"Email") ?>" id="user_email" class="input" required_ /> </p> <p class="login-password"> <input type="password" name="user_password" placeholder="<?php echo nl("PW",get_locale(),"Password") ?>" id="user_password" class="input" required_ /> </p> <input type="hidden" name="action" value="register_hit"> <div class="hit_error"></div> <?php do_action('register_form'); ?> <input type="submit" class="button product_type_simple add_to_cart_button ajax_add_to_cart added" value="<?php echo nl("R",get_locale(),"Register") ?>" id="register" /> </form> <script type="text/javascript"> jQuery(document).ready(function($){ jQuery("#custom-registration").submit(function(){ jQuery.ajax({ url:woocommerce_params.ajax_url, type:'POST', dataType:'json', data:$("#custom-registration").serialize(), beforeSend:function(){ jQuery("#register").val("Loading...").prop("disabled",true); }, complete:function(){ jQuery("#register").val("<?php echo nl("R",get_locale(),"Register") ?>").prop("disabled",false); }, success:function(json){ jQuery(".hit_error").html('').removeClass("woocommerce-error"); if(json['success']){ location.reload(); } if(json['error']){ jQuery(".hit_error").html(json['error']).addClass("woocommerce-error"); } }, }) return false; }) }) </script> </div> </div> </div> <?php } ?> <?php } ?> <?php if ( is_user_logged_in()) { ?> <h1><?php echo nl("YBI",get_locale(),"Your Billing Information"); ?></h1> <?php } ?> <form name="checkout" method="post" class="checkout woocommerce-checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data"> <?php if ( is_user_logged_in()) { if ( $checkout->get_checkout_fields() ){ ?> <?php do_action( 'woocommerce_checkout_before_customer_details' ); ?> <div class="col2-set" id="customer_details"> <div class="col-1 billing_checkout"> <?php do_action( 'woocommerce_checkout_billing' ); ?> </div> <div class="col-2"> <?php do_action( 'woocommerce_checkout_shipping' ); ?> </div> </div> <script > <?php $current_user = get_currentuserinfo(); ?> jQuery(function() { var first_name = '<?php echo (isset($current_user->user_firstname))?$current_user->user_firstname:' ';?>'; var filled = jQuery("#billing_first_name").val().length; if(!filled){ jQuery("#billing_first_name").val(first_name); } }); </script> <?php //var_dump(get_currentuserinfo());?> <?php do_action( 'woocommerce_checkout_after_customer_details' ); ?> <?php } } ?> <?php if ( is_user_logged_in()) { ?> <h3 id="order_review_heading"><?php _e( 'Your order', 'woocommerce' ); ?></h3> <?php do_action( 'woocommerce_checkout_before_order_review' ); ?> <div id="order_review" class="woocommerce-checkout-review-order"> <?php do_action( 'woocommerce_checkout_order_review' ); ?> </div> <?php do_action( 'woocommerce_checkout_after_order_review' ); ?> <?php } ?> </form> </div> </div> </div> </div> <?php do_action( 'woocommerce_after_checkout_form', $checkout ); ?>
- The topic ‘Captcha visible, but not validating’ is closed to new replies.