I see you have a filter:
yikes-mailchimp-after-submission and yikes-mailchimp-after-submission-{$form_id} β Catch the merge variables after they get sent over to MailChimp. @params: $merge_variables
I call call this filter to have the email sent, right? But what code should I write to send an email to a specific email from the wordpress? I am not a code expert so if you could help I would be really glad π
Thanks.
Hi @magaworks,
This is a simple example of how to use the yikes-mailchimp-form-submission hook. It will fire any time a successful submission is captured.
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 ) {
$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>';
$content .= print_r( $merge_variables, true );
$admin_email = '[email protected]';
$subject = 'New MailChimp Submission.';
$headers = array( 'Content-Type: text/html; charset=UTF-8' );
wp_mail( $admin_email, $subject, $content, $headers );
}
Cheers,
Kevin.
Can I get the Form Title?
I was able to get form ID but it would be nice to show the Form Title instead.
And can I also get de $merge_variables in a more readable way? Is there a way to show the variables like:
Name: XXXX
email: XXXXX
etc…
Thanks
Hey @magaworks,
Yup, replace your current snippet with this updated one.
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 . ': ' . $merge_value . '</p>';
}
$admin_email = '[email protected]';
$subject = 'New MailChimp Submission for Form: ' . $form_name;
$headers = array( 'Content-Type: text/html; charset=UTF-8' );
wp_mail( $admin_email, $subject, $content, $headers );
}
Hi, thanks for all the help.
About the form name it is not collecting that part for some reason: $form_name = $form_data[‘form_name’];
All the rest os perfect.
Thank you so much for the help
What is showing for $form_name? Does it just show “New MailChimp Submission for Form: “?
It does shoe that sentence too.
It starts the line below “A user with the email”
But I am not using the last version of wordpress, let me try updating it first.
Can you make sure you’re using the updated snippet? Can you paste the snippet you’re currently using here?
Thanks,
Kevin.
Sorry,
Everything works just fin.
My fault. I miss formated a line when translating to my language.
Now It all works just Fine!!!
Thanks a lot again