send_new_noptin_subscriber_double_optin_email( int $id, array $fields,  $force = false )

Sends double optin emails.


Parameters Parameters

$id

(int) (Required) The id of the new subscriber.

$fields

(array) (Required) The subscription field values.


Top ↑

Source Source

File: includes/subscriber.php

function send_new_noptin_subscriber_double_optin_email( $id, $fields, $force = false ) {

	// Is double optin enabled?
	$double_optin = get_noptin_option( 'double_optin' );
	if ( empty( $double_optin ) && ! $force ) {
		return false;
	}

	$url      = esc_url_raw( get_noptin_action_url( 'confirm', $fields['confirm_key'] ) );
	$link     = "<a href='$url' target='_blank'>$url</a>";
	$defaults = get_default_noptin_subscriber_double_optin_email();

	$data = array (
		'email_subject'   => get_noptin_option( 'double_optin_email_subject', $defaults['email_subject'] ),
		'merge_tags'      => array(
			'confirmation_link' => $link,
			'confirmation_url'  => $url,
		),
		'hero_text'       => get_noptin_option( 'double_optin_hero_text', $defaults['hero_text'] ),
		'email_body'      => get_noptin_option( 'double_optin_email_body', $defaults['email_body'] ),
		'cta_url'         => $url,
		'cta_text'        => get_noptin_option( 'double_optin_cta_text', $defaults['cta_text'] ),
		'after_cta_text'  => get_noptin_option( 'double_optin_after_cta_text', $defaults['after_cta_text'] ),
		'permission_text' => get_noptin_option( 'double_optin_permission_text', $defaults['permission_text'] ),
		'email'			  => $fields['email'],
		'email_type'      => 'double_optin',
	);

	foreach ( $fields as $key => $value ) {

		if ( is_scalar( $key ) ) {
			$data['merge_tags'][ $key ] = $value;
		}

	}

	$data['merge_tags'] = array_merge( get_noptin_subscriber_merge_fields( $id ), $data['merge_tags'] );

	// Allow users to filter the double opt-in email.
	foreach ( $data as $key => $value ) {
		$data[ $key ] = apply_filters( "noptin_double_optin_$key", $value );
	}

	$data = apply_filters( 'noptin_double_optin_data', $data );

	// Send the email.
	return noptin()->mailer->prepare_then_send( $data );

}


Top ↑

Changelog Changelog

Changelog
VersionDescription
1.2.4Introduced.

Top ↑

User Contributed Notes User Contributed Notes

30 day money back guarantee
Safe & Secure online payment
Custom CSS Slide Example
Custom Animation Example
Default Animation