Automattic\WooCommerce\Internal\CustomerEmailVerification

EmailVerificationService::seconds_since_last_keypublicWC 11.0.0

Return the number of seconds elapsed since the last verification key was issued, or null if none exists.

Method of the class: EmailVerificationService{}

No Hooks.

Returns

int|null. Seconds since the last key was created, or null when none is stored.

Usage

$EmailVerificationService = new EmailVerificationService();
$EmailVerificationService->seconds_since_last_key( $user_id ): ?int;
$user_id(int) (required)
WordPress user ID.

Changelog

Since 11.0.0 Introduced.

EmailVerificationService::seconds_since_last_key() code WC 11.0.1

public function seconds_since_last_key( int $user_id ): ?int {
	$parsed = $this->parse_stored_key( $user_id );

	if ( null === $parsed ) {
		return null;
	}

	// Clamp to zero so a future timestamp (clock skew, migrations) can't report negative
	// elapsed time and wedge the resend rate-limit / "recently sent" notice logic.
	return max( 0, time() - $parsed[0] );
}