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.
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_option( 'admin_email' ); $subject = sprintf( __( '[%s] New Subscriber', 'newsletter-optin-box' ), $blogname ); @wp_mail( $to, wp_specialchars_decode( $subject ), $message ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.2.0 | Introduced. |