Files
ogre-captcha/inc/location/woocommerce/class-register.php
T
Cooper Dalrymple 9ad3558ac4
Validate Build / validate-build (push) Failing after 29s
Update version to 1.0.0
2026-06-04 17:52:08 -05:00

49 lines
1.1 KiB
PHP

<?php
/**
* @package ogre-captcha
* @author cleverogre
* @copyright 2026 CleverOgre
* @license GLP-3.0-or-later
* @version 1.0.0
* @since 1.0.0
*/
namespace Ogre\Captcha\Location\WooCommerce;
use Override;
use Ogre\Captcha\Location;
use Ogre\Captcha\Settings;
use WP_Error;
defined('ABSPATH') || exit;
final class Register extends Location {
protected function __construct() {
parent::__construct(Settings::LOCATION_WC_REGISTER);
}
#[Override]
public function enabled(): bool
{
return is_user_logged_in() ? false : parent::enabled();
}
#[Override]
public function activate(): void
{
add_action('woocommerce_register_form', [$this, 'render']);
if (isset($_POST['woocommerce-register-nonce'])) {
add_filter('woocommerce_process_registration_errors', [$this, 'process_form'], 10, 4);
}
}
public function process_form(WP_Error $validation_error, string $username, string $password, string $email):WP_Error {
$this->process($validation_error);
return $validation_error;
}
}
Register::instance();