Automattic\WooCommerce\Internal\CustomerEmailVerification
EmailVerificationService::parse_stored_key
Parse the stored verification token into its timestamp, key-hash, and email-hash parts.
The token is persisted as "{timestamp}:{key_hash}:{email_hash}"; this is the single place that knows that format.
Method of the class: EmailVerificationService{}
No Hooks.
Returns
array{0: int, 1: string, 2: string}|null. The triplet, or null when none is stored.
Usage
// private - for code of main (parent) class only $result = $this->parse_stored_key( $user_id ): ?array;
- $user_id(int) (required)
- WordPress user ID.
EmailVerificationService::parse_stored_key() EmailVerificationService::parse stored key code WC 11.0.1
private function parse_stored_key( int $user_id ): ?array {
$stored = (string) Users::get_site_user_meta( $user_id, self::KEY_META );
if ( ! str_contains( $stored, ':' ) ) {
return null;
}
$parts = explode( ':', $stored, 3 );
$timestamp = (int) ( $parts[0] ?? 0 );
$hash = (string) ( $parts[1] ?? '' );
$email_hash = (string) ( $parts[2] ?? '' );
if ( '' === $hash || '' === $email_hash || 0 === $timestamp ) {
return null;
}
return array( $timestamp, $hash, $email_hash );
}