noptin_new_subscriber_notify( int $id, array $fields )

Notifies the site admin when there is a new subscriber.


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 noptin_new_subscriber_notify( $id, $fields ) {

	// Are we sending new subscriber notifications?
	$notify = get_noptin_option( 'notify_admin' );
	if ( empty( $notify ) ) {
		return;
	}

	// The blogname option is escaped with esc_html on the way into the database in sanitize_option.
	// we want to reverse this for the plain text arena of emails.
	$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );

	/* translators: %s: site title */
	$message = sprintf( __( '%s has a new email subscriber', 'newsletter-optin-box' ), $blogname ) . "\r\n\r\n";

	unset( $fields['Email'] );
	unset( $fields['name'] );

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

		if ( ! empty( $val ) && is_scalar( $val ) ) {
			$message .= sprintf( '%s: %s', sanitize_text_field( $key ), esc_html( $val ) ) . "\r\n";
		}
	}

	$to = get_noptin_option( 'admin_email',  get_option( 'admin_email' ) );

	if ( empty( $to ) ) {
		$to = get_option( 'admin_email' );
	}

	$subject = sprintf( __( '[%s] New Subscriber', 'newsletter-optin-box' ), $blogname );

	@wp_mail( noptin_parse_list( $to ), wp_specialchars_decode( $subject ), $message );

}


Top ↑

Changelog Changelog

Changelog
VersionDescription
1.2.0Introduced.

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