Files
ogre-captcha/inc/location/class-registration-page.php
T
2026-06-09 12:53:19 -05:00

57 lines
1.3 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;
use Override;
use Ogre\Captcha\LoginLocation;
use Ogre\Captcha\Settings;
use WP_Error;
defined('ABSPATH') || exit;
final class RegistrationPage extends LoginLocation {
protected function __construct() {
parent::__construct(Settings::LOCATION_REGISTRATION_PAGE, 'register');
}
#[Override]
public function enabled(): bool
{
return is_user_logged_in() ? false : parent::enabled();
}
#[Override]
public function activate(): void
{
if (is_multisite()) {
add_action('signup_extra_fields', [$this, 'render']);
add_filter('wpmu_validate_user_signup', [$this, 'process_multisite_form']);
} else {
add_action('register_form', [$this, 'render']);
}
add_filter('registration_errors', [$this, 'process_form'], 10, 3);
}
public function process_multisite_form(array $result):array {
$this->process($result['errors']);
return $result;
}
public function process_form(WP_Error $errors, string $sanitized_user_login, string $user_email):WP_Error {
$this->process($errors);
return $errors;
}
}
RegistrationPage::instance();