Check User Verification Status

This function is useful for developers who need to programmatically determine whether a user’s email has been verified or not within the WooCommerce environment.

function cev_check_user_verification_status( $user_id ) {
	
	// Initialize verification status to false.
	$verification = false;
	
	// Get the value of 'customer_email_verified' user meta field for the specified user.
	$verified = get_user_meta( $user_id, 'customer_email_verified', true );
	
	// Check if the value is 'true' to set the verification status to true.
	if ( 'true' == $verified ) {
		$verification = true;
	} else {
		// If the value is not 'true', set the verification status to false.
		$verification = false;
	}
	
	// Return the final verification status.
	return $verification;
}

Description

  1. The function initializes the verification status to false.
  2. It retrieves the value of the ‘customer_email_verified’ user meta field for the specified user using get_user_meta.
  3. If the value is ‘true’, the verification status is set to true.
  4. If the value is not ‘true’, the verification status is set to false.
  5. The final verification status is returned.

$119.00

Billed annually

Buy Now