Last active
June 11, 2016 01:17
-
-
Save groucho75/1d44d76304ed6e2774a7a8c55a156fc0 to your computer and use it in GitHub Desktop.
ALO-CF7 Integration - Updated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function my_easymail_add_subscriber ( $cf7 ) { | |
$submission = WPCF7_Submission::get_instance(); | |
$data = $submission->get_posted_data(); | |
$fields['email'] = $data["your-email"]; | |
$fields['name'] = $data["your-name"]; | |
if ( function_exists ('alo_em_add_subscriber') && is_email( $fields['email'] ) ) | |
{ | |
alo_em_add_subscriber( $fields, 1, alo_em_get_language(true) ); | |
$subscriber = alo_em_get_subscriber( $fields['email'] ); | |
if ( ! empty( $data["easymail-lists"][0] ) ) { | |
foreach( $data["easymail-lists"] as $list_id ) { | |
alo_em_add_subscriber_to_list ( $subscriber->ID, $list_id ); | |
} | |
} | |
} | |
return $cf7; | |
} | |
add_action( 'wpcf7_before_send_mail', 'my_easymail_add_subscriber' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Alo,
Great work. I integrated the instructions with the file and added . The file can be dropped into /wp-content/plugins/ and it just works (both for single installs and for multisite). This should help all the other folks who have the same desire to integrate with CF7.
See: https://gist.github.com/jeffmcneill/e7a53e11979ceddf81ec6c4764057c76