Email the Team About New Newsletter Signups
Sends a short email to your team each time someone subscribes through a Mailchimp for WordPress form, including the form name and page, for low-volume lists where every lead counts.
Opens WPIDE on
Code
$wpide_notify_to = get_option( 'admin_email' ); // Recipient(s).
add_action( 'mc4wp_form_subscribed', function ( $form, $email ) use ( $wpide_notify_to ) {
$page = wp_get_referer();
wp_mail(
$wpide_notify_to,
sprintf( '[%s] New newsletter subscriber', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ),
sprintf(
"Email: %1\$s\nForm: %2\$s\nPage: %3\$s\nTime: %4\$s\n",
sanitize_email( $email ),
is_object( $form ) && isset( $form->name ) ? $form->name : '-',
$page ? $page : '-',
wp_date( 'Y-m-d H:i' )
)
);
}, 10, 2 );
Notes
Set $wpide_notify_to. Not recommended for lists with dozens of signups per day.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.