Last active
May 12, 2016 18:15
-
-
Save rothschild86/d126fdff104f4a17324f91827c63e831 to your computer and use it in GitHub Desktop.
Caldera Forms to MyMail integration
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
<?php | |
//* Do NOT include the opening php tag shown above. Copy the code shown below. | |
//required plugins: code snippets, caldera forms, caldera forms run action, mymail | |
add_action('consult_req_submitted', 'consult_req_submitted_sync_mymail'); //as defined in caldera forms run action | |
function consult_req_submitted_sync_mymail( $data ){ | |
$caldera_name = $data[ 'your_name' ]; //this is the caldera field slug | |
$caldera_email = $data[ 'email' ]; //this is the caldera field slug | |
try { | |
if (function_exists('mymail')) { | |
$entry = array( | |
'firstname' => $caldera_name, | |
'email' => $caldera_email, | |
'status' => 1, //1 = subscribed (default) , 0 = pending, 2 = unsubscribed, 3 = hardbounced | |
'ip' => $_SERVER['REMOTE_ADDR'], | |
'signup_ip' => $_SERVER['REMOTE_ADDR'], | |
'referer' => $_SERVER['HTTP_REFERER'], | |
'signup' =>time(), | |
'source' => 'Self subscribed', //custom field | |
'drawing-eligible' => 'yes' //custom field | |
); | |
$subscriber_id = mymail('subscribers')->add($entry, false); //false==do not override | |
if (is_wp_error( $subscriber_id )) return; | |
$list_ids = array(1); | |
$result = mymail('subscribers')->assign_lists($subscriber_id, $list_ids); | |
} | |
} catch (Exception $e) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment