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 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' ); |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Jeff, first of all thanks a lot for your contribute :)
I hope the above code should be ok for you.
After adding it in /mu-plugins folder or in your theme functions.php, you have to setup the form created with CF7:
easymail-lists
to match the above script. So something like:[checkbox easymail-lists use_label_element "list one|1" list two|2" "list three|3" "list four|4"]
use the pipe (http://contactform7.com/selectable-recipient-with-pipes/) to set the lists: the list name - the pipe - the EasyMail list ID.
It's important that the IDs match with EasyMail mailing list IDs you can find them in plugin settings.
[_raw_easymail-lists]
to show the selected list labels. Otherwise the standard[easymail-lists]
shows the IDs.I hope it helps.