add_filter( 'woocommerce_registration_errors', 'wf_woocommerce_registration_errors', 10, 3 );
function wf_woocommerce_registration_errors( $errors, $username, $email ) {

    // --- reCAPTCHA v3 verification ---
    if ( defined( 'WF_RECAPTCHA_SECRET_KEY' ) && WF_RECAPTCHA_SECRET_KEY ) {
        $token = isset( $_POST['g-recaptcha-response'] ) ? sanitize_text_field( wp_unslash( $_POST['g-recaptcha-response'] ) ) : '';

        if ( empty( $token ) ) {
            $errors->add( 'captcha_error', __( '<strong>Error</strong>: Bot verification failed. Please refresh the page and try again.', 'warranty-form' ) );
        } else {
            $response = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', array(
                'timeout' => 15,
                'body'    => array(
                    'secret'   => WF_RECAPTCHA_SECRET_KEY,
                    'response' => $token,
                    'remoteip' => $_SERVER['REMOTE_ADDR'] ?? '',
                ),
            ) );

            if ( is_wp_error( $response ) ) {
                $errors->add( 'captcha_error', __( '<strong>Error</strong>: Unable to verify reCAPTCHA. Please try again.', 'warranty-form' ) );
            } else {
                $body = json_decode( wp_remote_retrieve_body( $response ), true );

                // v3 returns success + score (0.0 - 1.0) + action
                $success = ! empty( $body['success'] );
                $score   = isset( $body['score'] ) ? floatval( $body['score'] ) : 0;
                $action  = $body['action'] ?? '';

                if ( ! $success || $score < 0.5 || $action !== 'register' ) {
                    $errors->add( 'captcha_error', __( '<strong>Error</strong>: Bot detection failed. If you are human, please try again.', 'warranty-form' ) );
                }
            }
        }
    }

    // --- Your existing field validation ---
    if ( empty( $_POST['first_name'] ) ) {
        $errors->add( 'first_name_error', __( '<strong>Error</strong>: First name is required.', 'warranty-form' ) );
    }
    if ( empty( $_POST['last_name'] ) ) {
        $errors->add( 'last_name_error', __( '<strong>Error</strong>: Last name is required.', 'warranty-form' ) );
    }
    if ( empty( $_POST['custom_role'] ) ) {
        $errors->add( 'custom_role_error', __( '<strong>Error</strong>: Please select a role.', 'warranty-form' ) );
    }
    if ( ! empty( $_POST['custom_role'] )
        && 'employee' !== $_POST['custom_role']
        && empty( $_POST['region'] ) ) {
        $errors->add( 'region_error', __( '<strong>Error</strong>: Please select a region.', 'warranty-form' ) );
    }

    return $errors;
}<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//qwatt.co/wp-content/plugins/wordpress-seo/css/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://qwatt.co/post-sitemap.xml</loc>
		<lastmod>2025-03-19T04:41:57+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://qwatt.co/page-sitemap.xml</loc>
		<lastmod>2026-04-19T08:38:14+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://qwatt.co/pxl-template-sitemap.xml</loc>
		<lastmod>2025-10-09T11:24:50+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://qwatt.co/portfolio-sitemap.xml</loc>
		<lastmod>2024-09-03T07:44:09+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://qwatt.co/product-sitemap.xml</loc>
		<lastmod>2026-01-21T12:41:15+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://qwatt.co/awsm_job_openings-sitemap.xml</loc>
		<lastmod>2025-03-18T08:28:01+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://qwatt.co/woolentor-template-sitemap.xml</loc>
		<lastmod>2025-02-13T05:42:36+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://qwatt.co/wpr_templates-sitemap.xml</loc>
		<lastmod>2025-02-20T07:18:47+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://qwatt.co/category-sitemap.xml</loc>
		<lastmod>2025-03-19T04:41:57+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://qwatt.co/post_tag-sitemap.xml</loc>
		<lastmod>2025-03-19T04:41:57+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://qwatt.co/portfolio-category-sitemap.xml</loc>
		<lastmod>2024-09-03T07:44:09+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://qwatt.co/product_cat-sitemap.xml</loc>
		<lastmod>2026-01-21T12:41:15+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://qwatt.co/job-type-sitemap.xml</loc>
		<lastmod>2025-03-18T08:28:01+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://qwatt.co/job-location-sitemap.xml</loc>
		<lastmod>2025-03-18T08:28:01+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://qwatt.co/author-sitemap.xml</loc>
		<lastmod>2025-03-25T09:25:26+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Yoast SEO -->