Automattic\WooCommerce\Internal\CustomerEmailVerification

VerificationController::should_show_prompt │ public │ WC 11.0.0

Return whether the verification prompt should be shown for the current user.

This cannot depend on whether matching guest orders exist, since that would disclose order existence before the customer proves they control the email address.

Метод класса: VerificationController{}

Возвращает

bool.

Использование

$VerificationController = new VerificationController();
$VerificationController->should_show_prompt(): bool;

Список изменений

С версии 11.0.0 Введена.

Код VerificationController::should_show_prompt() WC 11.2.2

public function should_show_prompt(): bool {
	$user_id = get_current_user_id();

	if ( ! $user_id || $this->service->is_verified( $user_id ) ) {
		return false;
	}

	$email_setting = get_option( 'woocommerce_customer_verify_email_settings', array() );
	$email_enabled = 'yes' === ( $email_setting['enabled'] ?? 'yes' );

	$should_show = $email_enabled && wc_string_to_bool( get_option( 'woocommerce_enable_guest_checkout' ) );

	// A temporary-password account already has a set-password link (which also verifies on use),
	// surfaced by the temporary-password notice, so skip a second prompt alongside it.
	$should_show = $should_show && ! get_user_option( 'default_password_nag', $user_id );

	/**
	 * Filter whether to show the verification prompt for an unverified user.
	 *
	 * @since 11.1.0
	 *
	 * @param bool $should_show Whether to show the prompt, before this filter runs.
	 * @param int  $user_id     The WordPress user ID of the customer.
	 */
	return (bool) apply_filters( 'woocommerce_customer_email_verification_should_show_prompt', $should_show, $user_id );
}