# double-opt-in/3.1.0/OnUpdate.php

Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification, version 3.1.0. 87 lines.

- Page: https://pluginprobe.com/plugins/double-opt-in/3.1.0/code/OnUpdate.php
- Raw: https://pluginprobe.com/plugins/double-opt-in/3.1.0/raw/OnUpdate.php
- Modified: 2025-09-23T13:34:24+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/double-opt-in/3.1.0/code/OnUpdate.php#L10-L20`.

```php
<?php

namespace forge12\contactform7\CF7DoubleOptIn;

use Forge12\Shared\Logger;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

function onUpdate() {
	$logger = Logger::getInstance();

	$logger->info( 'Running onUpdate routine', [
		'plugin' => 'double-opt-in',
		'class'  => __CLASS__ ?? null,
		'method' => __FUNCTION__,
	] );

	$currentVersion = get_site_option( FORGE12_OPTIN_SLUG . '_version' );

	if ( version_compare( $currentVersion, '1.7' ) < 0 ) {
		$logger->info( 'Updating to version 1.7', [
			'plugin'  => 'double-opt-in',
			'current' => $currentVersion,
			'target'  => '1.7',
		] );

		createTableOptinCategories();
		$logger->debug( 'createTableOptinCategories executed', [
			'plugin' => 'double-opt-in',
		] );

		createTableOptin();
		$logger->debug( 'createTableOptin executed', [
			'plugin' => 'double-opt-in',
		] );

		update_option( FORGE12_OPTIN_SLUG . '_version', '1.7' );
		$logger->info( 'Version updated to 1.7', [
			'plugin' => 'double-opt-in',
		] );
	}

	if ( version_compare( $currentVersion, '2.0' ) < 0 ) {
		$logger->info( 'Updating to version 2.0', [
			'plugin'  => 'double-opt-in',
			'current' => $currentVersion,
			'target'  => '2.0',
		] );

		createTableOptin();
		$logger->debug( 'createTableOptin executed', [
			'plugin' => 'double-opt-in',
		] );

		update_option( FORGE12_OPTIN_SLUG . '_version', '2.0' );
		$logger->info( 'Version updated to 2.0', [
			'plugin' => 'double-opt-in',
		] );
	}

	if ( version_compare( $currentVersion, '3.0.1' ) < 0 ) {
		$logger->info( 'Updating to version 3.0.1', [
			'plugin'  => 'double-opt-in',
			'current' => $currentVersion,
			'target'  => '3.0.1',
		] );

		createTableOptin();
		$logger->debug( 'createTableOptin executed', [
			'plugin' => 'double-opt-in',
		] );

		update_option( FORGE12_OPTIN_SLUG . '_version', '3.0.1' );
		$logger->info( 'Version updated to 3.0.1', [
			'plugin' => 'double-opt-in',
		] );
	}

	$logger->info( 'onUpdate routine finished', [
		'plugin' => 'double-opt-in',
	] );
}

onUpdate();

```
