Automattic\WooCommerce\Internal\CustomerEmailVerification
VerificationController::handle_send_request
Handle a request to send (or resend) the verification email, triggered by the My Account prompt.
Verifies the nonce, applies a rate-limit (does not re-send within the window), dispatches the email, and redirects to the orders section, where the prompt points the customer to their inbox.
Method of the class: VerificationController{}
No Hooks.
Returns
null. Nothing (null).
Usage
$VerificationController = new VerificationController(); $VerificationController->handle_send_request(): void;
Changelog
| Since 11.0.0 | Introduced. |
VerificationController::handle_send_request() VerificationController::handle send request code WC 11.0.0
public function handle_send_request(): void {
$user_id = get_current_user_id();
if ( ! $user_id ) {
return;
}
$nonce = isset( $_GET['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_GET['_wpnonce'] ) ) : '';
if ( ! wp_verify_nonce( $nonce, self::SEND_NONCE_ACTION ) ) {
$this->redirect_with_result( 'invalid' );
}
// Only send a fresh link once the last one is outside the rate-limit window; otherwise the
// existing link still stands and the prompt continues to point the customer to their inbox.
$seconds_since = $this->service->seconds_since_last_key( $user_id );
if ( null === $seconds_since || $seconds_since >= self::SEND_RATE_LIMIT ) {
$this->send_verification_email( $user_id );
$this->redirect_with_result( 'sent' );
}
$this->redirect_with_result( 'throttled' );
}