Add woocommerce form locations
Validate Build / validate-build (push) Failing after 27s
Validate Build / validate-build (push) Failing after 27s
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* @package ogre-captcha
|
||||
* @author cleverogre
|
||||
* @copyright 2026 CleverOgre
|
||||
* @license GLP-3.0-or-later
|
||||
* @version 0.0.0
|
||||
* @since 0.0.0
|
||||
*/
|
||||
|
||||
namespace Ogre\Captcha\Location\WooCommerce;
|
||||
|
||||
use Override;
|
||||
use Ogre\Captcha\Location;
|
||||
use Ogre\Captcha\Settings;
|
||||
use WP_Error;
|
||||
use WP_User;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
final class LostPassword extends Location {
|
||||
|
||||
protected function __construct() {
|
||||
parent::__construct(Settings::LOCATION_WC_LOST_PASSWORD);
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function enabled(): bool
|
||||
{
|
||||
return is_user_logged_in() ? false : parent::enabled();
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function activate(): void
|
||||
{
|
||||
add_action('woocommerce_lostpassword_form', [$this, 'render']);
|
||||
if (isset($_POST['woocommerce-lost-password-nonce'])) {
|
||||
add_action('lostpassword_post', [$this, 'process_form']);
|
||||
}
|
||||
}
|
||||
|
||||
public function process_form(WP_Error $errors, WP_User|bool $user_data) {
|
||||
$this->process($errors);
|
||||
// NOTE: Potentially use `allow_password_reset` to display error message?
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LostPassword::instance();
|
||||
Reference in New Issue
Block a user