' . wp_kses_post($css_by_option) . '';
}
// Redirect if the user is already logged in
if (is_user_logged_in()) {
echo "";
}
// Error handling
if (isset($error) && !empty($error)) {
echo '
';
foreach ($error as $error_show) {
echo '
' . esc_html($error_show) . "
";
}
echo '
';
}
// reCAPTCHA keys
$recaptcha_keys = get_option('custom_reCapatcha_value');
// Handling POST request
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['password'])) {
// Validate nonce
if (isset($_POST['user_registration_nonce_field']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['user_registration_nonce_field'])), 'user_registration_nonce')) {
// Check reCAPTCHA
if (isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])) {
$captcha = sanitize_text_field(wp_unslash($_POST['g-recaptcha-response']));
$secretKey = $recaptcha_keys['author_reCap_secrectkey'];
$remoteip = isset($_SERVER['REMOTE_ADDR']) ? sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])) : 'Unknown';
$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$secretKey&response=$captcha&remoteip=$remoteip");
$responseKeys = json_decode($response, true);
if (intval($responseKeys["success"]) !== 1) {
$error[] = "Captcha verification failed!";
} else {
// Process form data after reCAPTCHA is valid
$username = isset($_POST['username']) ? sanitize_text_field(wp_unslash($_POST['username'])) : '';
$email = isset($_POST['email']) ? sanitize_email(wp_unslash($_POST['email'])) : '';
// Additional form processing here (e.g., save user data)
echo "Form submitted successfully!";
}
} else {
$error[] = "Please complete the CAPTCHA!";
}
} else {
$error[] = "Security check failed!";
}
}
?>