Hi Gerardo,
We don’t support sending email from our plugin because email is complicated and each site might handle their mail differently.
However, we do have a few snippets that I’ve given out and that I know a few of our users use.
Make sure to replace YOUR-EMAIL-HERE with your email address.
This snippet will send an email whenever the form is submitted (i.e. successful and unsuccessful submissions).
add_action( 'yikes-mailchimp-form-submission', 'yikes_send_email_after_submission', 10, 4 );
function yikes_send_email_after_submission( $email, $merge_variables, $form_id, $notifications ) {
$interface = yikes_easy_mailchimp_extender_get_form_interface();
$form_data = $interface->get_form( $form_id );
$form_name = $form_data['form_name'];
$content = '<p>MailChimp Submission for Form: ' . $form_name . '</p>';
$content .= '<p>A user with the email ' . $email . ' has attempted to subscribe to your MailChimp list.</p>';
$content .= '<p>Here is their information: </p><br>';
foreach ( $merge_variables as $merge_tag => $merge_value ) {
$content .= '<p>' . $merge_tag . ': ' . ( is_array( $merge_value ) ? implode( ', ', $merge_value ) : $merge_value ) . '</p>';
}
$admin_email = 'YOUR-EMAIL-HERE';
$subject = 'New MailChimp Submission for Form: ' . $form_name;
$headers = array( 'Content-Type: text/html; charset=UTF-8' );
wp_mail( $admin_email, $subject, $content, $headers );
}
This snippet will send an email for successful submissions (it also doesn’t include as much data as the previous snippet).
add_action( 'yikes-mailchimp-after-submission', 'yikes_send_email_after_successful_submission', 10, 1 );
function yikes_send_email_after_successful_submission( $merge_variables ) {
$content .= '<p>A user has subscribed to your MailChimp list.</p>';
$content .= '<p>Here is their information: </p><br>';
foreach ( $merge_variables as $merge_tag => $merge_value ) {
$content .= '<p>' . $merge_tag . ': ' . ( is_array( $merge_value ) ? implode( ', ', $merge_value ) : $merge_value ) . '</p>';
}
$admin_email = 'YOUR-EMAIL-HERE';
$subject = 'New MailChimp Submission';
$headers = array( 'Content-Type: text/html; charset=UTF-8' );
wp_mail( $admin_email, $subject, $content, $headers );
}
Cheers,
Kevin.
Hey Kevin,
Thanks a lot! Everything works now.
Regards,
Gerardo
Hi Kevin,
Can you tell me where this snippet gets added? Thanks in advance.
Marc
-
This reply was modified 7 years, 4 months ago by
Marc.
Hi Marc,
This snippet should be added to your child theme’s functions.php file. If you’re not using a child theme, then you can add it to your theme’s functions.php file or use a plugin like My Custom Functions.
Cheers,
Kevin.