function SF_Account_Upsert166($entry, $form) { //upload information to salesforce from the final form. global $wpdb; ini_set("soap.wsdl_cache_enabled", "0"); $USERNAME = "******"; //- variable that contains your Salesforce.com username (must be in the form of an email) $PASSWORD = "******"; //- variable that contains your Salesforce.com password $TOKEN = "qhO7UhNTUrYp8XU5eF1SRomDp"; //- variable that contains your Salesforce.com password require_once ABSPATH . '/soapclient/SforceEnterpriseClient.php'; require_once ABSPATH . '/soapclient/SforceHeaderOptions.php'; // Salesforce Login information $wsdl = ABSPATH . '/soapclient/eSNenterprise.wsdl.xml'; $mySforceConnectionu = new SforceEnterpriseClient(); $mySoapClient = $mySforceConnectionu->createConnection($wsdl); $mylogin = $mySforceConnectionu->login($USERNAME, $PASSWORD . $TOKEN); $loginname = $entry[30]; $thenewuser = get_user_by('login', $loginname); if ($thenewuser) { $user_id = $thenewuser->ID; } else { sleep(1); $thenewuser = get_user_by('login', $loginname); $user_id = $thenewuser->ID; } $newperson = array(); $newperson['WP_Unique_ID__c'] = $user_id; $newperson['WP_ID__c'] = $user_id; $newperson['Source__c'] = $_SERVER["SERVER_NAME"]; $newperson['Site_Registered_On__c'] = $_SERVER["SERVER_NAME"]; $wp_subreq_id = '21' . $entry[4]; //21 = digital ecn [4] is email $newSubReq = array(); // array for subscription $newSubReq['Source__c'] = "Web"; //$newSubReq['WP_ID__c'] = $user_id; $newSubReq['WP_ID__c'] = substr($wp_subreq_id, 0, 20); //need to limit length to 20 characters $newSubReq["Sub_Status__c"] = 'Pending'; $newSubReq['Personal_Question__c'] = $entry[59]; $newSubReq['Promo_Code__c'] = "Registration"; $newSubReq['Renewal_Link__c'] = substr(${$entry}[18], 0, 254); $newSubReq['Request_Date__c'] = date("Y-m-d"); $newSubReq['Request_URL__c'] = $_SERVER["SERVER_NAME"]; $newSubReq["Name"] = 'eCampus News Digital Subscription'; if (!empty($entry[30])) { $newperson['WP_Login__c'] = strtolower($entry[30]); } if (!empty($entry[4])) { $newperson['PersonEmail'] = $entry[4]; $newSubReq['Email__c'] = $entry[4]; $newperson['Email_as_ExternalID__c'] = $entry[4]; //12-20-2011 } if (!empty($entry[1])) { $newperson['FirstName'] = $entry[1]; $newSubReq['First_Name__c'] = $entry[1]; } if (!empty($entry[2])) { $newperson['LastName'] = $entry[2]; $newSubReq['Last_Name__c'] = $entry[2]; } if (!empty($entry[61])) { $newperson['Unique_Title__c'] = $entry[61]; $newSubReq['Unique_Title__c'] = $entry[61]; } if (!empty($entry[3])) { $newperson['Organization__c'] = $entry[3]; $newSubReq['Organization__c'] = $entry[3]; } if (!empty($entry[5])) { $newperson['PersonTitle'] = $entry[5]; $newSubReq['Title__c'] = $entry[5]; } if (!empty($entry[6])) { $newperson['Company_Type__c'] = $entry[6]; $newSubReq['Organization_Type__c'] = $entry[6]; } if (!empty($entry[7])) { $newperson['PersonMailingStreet'] = $entry[7]; $newSubReq['Address1__c'] = $entry[7]; } if (!empty($entry[8])) { $newperson['Mailing_Address_2__c'] = $entry[8]; $newSubReq['Address2__c'] = $entry[8]; } if (!empty($entry[9])) { $newperson['PersonMailingCity'] = $entry[9]; $newSubReq['city__c'] = $entry[9]; } if (!empty($entry[10])) { $newperson['PersonMailingState'] = $entry[10]; $newSubReq['State__c'] = $entry[10]; } if (!empty($entry[12])) { $newperson['PersonMailingPostalCode'] = $entry[12]; $newSubReq['Zip__c'] = $entry[12]; } if (!empty($entry[13])) { $newperson['PersonMailingCountry'] = $entry[13]; $newSubReq['Country__c'] = $entry[13]; } if (!empty($entry[22])) { $newperson['Phone'] = $entry[22]; $newSubReq['Phone__c'] = $entry[22]; } if (!empty($entry[31])) { $newperson['Fax'] = $entry[31]; $newSubReq['Fax__c'] = $entry[31]; } if (!empty($entry[32])) { $newperson['Grade_Level__c'] = $entry[32]; } else { $newperson['Grade_Level__c'] = ""; } if (!empty($entry[33])) { $newperson['Subject_Taught__c'] = $entry[33]; } else { $newperson['Subject_Taught__c'] = ""; } if (!empty($entry[14])) { $newSubReq['Personal_Answer__c'] = $entry[14]; } $OptedOutflag = 0; if (!empty($entry['57.1'])) { $newperson['ecn_today__c'] = $entry['57.1']; if ($entry['57.1'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['ecn_today__c'] = "Not Subscribed"; } if (!empty($entry['57.2'])) { $newperson['eCN_This_Week__c'] = $entry['57.2']; if ($entry['57.2'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eCN_This_Week__c'] = "Not Subscribed"; } // <span style="cursor:Pointer;" title="Weekly on Wednesday"> eCampus IT Leadership<img src="/wp-content/themes/advanced-newspaper/images/info14.gif" /></span>|Subscribed if (!empty($entry['57.3'])) { $newperson['eCN_IT_School_Leadership__c'] = $entry['57.3']; if ($entry['57.3'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eCN_IT_School_Leadership__c'] = "Not Subscribed"; } if (!empty($entry['57.4'])) { $newperson['eCN_Offers__c'] = $entry['57.4']; if ($entry['57.4'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eCN_Offers__c'] = "Not Subscribed"; } if (!empty($entry['57.5'])) { $newperson['eCN_Partners__c'] = $entry['57.5']; if ($entry['57.5'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eCN_Partners__c'] = "Not Subscribed"; } $newperson['eSN_Today__c'] = "Not Subscribed"; $newperson['eSN_Tools_For_Schools__c'] = "Not Subscribed"; $newperson['Ed_Resource_Alert__c'] = "Not Subscribed"; $newperson['eClassroom_News__c'] = "Not Subscribed"; $newperson['eSN_This_Week__c'] = "Not Subscribed"; $newperson['eSN_Offers__c'] = "Not Subscribed"; $newperson['Partner_Offers__c'] = "Not Subscribed"; //special update unsub flag if they subscribe to anything... else do not change it. if ($OptedOutflag == 1) { $newperson['PersonHasOptedOutOfEmail'] = false; } $upsertResponse = $mySforceConnectionu->upsert('Email_as_ExternalID__c', array($newperson), 'Account'); //When if ($upsertResponse->success == 1) { update_user_meta($user_id, "sfid", $upsertResponse->id); update_user_meta($user_id, "PersonContactId", $upsertResponse->id); $newSubReq['Person_Account__c'] = $upsertResponse->id; //now that we have a new user account put in the my eschool news data if it is set $esm_change = '6|1|'; $seperator = ','; if (isset($_POST[input_54_1]) and $_POST[input_54_1] == 213) { $esm_change .= '213,'; } if (isset($_POST[input_54_2]) and $_POST[input_54_2] == 27) { $esm_change .= '27,'; } if (isset($_POST[input_54_3]) and $_POST[input_54_3] == 4) { $esm_change .= '4,'; } if (isset($_POST[input_54_4]) and $_POST[input_54_4] == 5351) { $esm_change .= '5351,'; } if (isset($_POST[input_54_5]) and $_POST[input_54_5] == 2303) { $esm_change .= '2303,'; } if (isset($_POST[input_54_6]) and $_POST[input_54_6] == 43) { $esm_change .= '43,'; } if (isset($_POST[input_54_7]) and $_POST[input_54_7] == 215) { $esm_change .= '215,'; } if (isset($_POST[input_54_8]) and $_POST[input_54_8] == 4217) { $esm_change .= '4217,'; } if (isset($_POST[input_54_9]) and $_POST[input_54_9] == 28) { $esm_change .= '28,'; } if (isset($_POST[input_54_11]) and $_POST[input_54_11] == 9) { $esm_change .= '9,'; } if (isset($_POST[input_54_12]) and $_POST[input_54_12] == 26) { $esm_change .= '26,'; } if (isset($_POST[input_54_13]) and $_POST[input_54_13] == 872) { $esm_change .= '872,'; } if (isset($_POST[input_54_14]) and $_POST[input_54_14] == 3) { $esm_change .= '3,'; } if (isset($_POST[input_54_15]) and $_POST[input_54_15] == 11) { $esm_change .= '11,'; } $esm_change = trim($esm_change, $seperator); $key = '_myesm_esn'; $single = true; update_user_meta($user_id, $key, $esm_change); //we did it so keep little data on the server... } else { //try again in one second... sleep(1); $upsertResponse = $mySforceConnectionu->upsert('Email_as_ExternalID__c', array($newperson), 'Account'); if ($upsertResponse->success == 1) { update_user_meta($user_id, "sfid", $upsertResponse->id); update_user_meta($user_id, "PersonContactId", $upsertResponse->id); $newSubReq['Person_Account__c'] = $upsertResponse->id; //now that we have a new user account put in the my eschool news data if it is set $esm_change = '6|1|'; $seperator = ','; if (isset($_POST[input_54_1]) and $_POST[input_54_1] == 213) { $esm_change .= '213,'; } if (isset($_POST[input_54_2]) and $_POST[input_54_2] == 27) { $esm_change .= '27,'; } if (isset($_POST[input_54_3]) and $_POST[input_54_3] == 4) { $esm_change .= '4,'; } if (isset($_POST[input_54_4]) and $_POST[input_54_4] == 5351) { $esm_change .= '5351,'; } if (isset($_POST[input_54_5]) and $_POST[input_54_5] == 2303) { $esm_change .= '2303,'; } if (isset($_POST[input_54_6]) and $_POST[input_54_6] == 43) { $esm_change .= '43,'; } if (isset($_POST[input_54_7]) and $_POST[input_54_7] == 215) { $esm_change .= '215,'; } if (isset($_POST[input_54_8]) and $_POST[input_54_8] == 4217) { $esm_change .= '4217,'; } if (isset($_POST[input_54_9]) and $_POST[input_54_9] == 28) { $esm_change .= '28,'; } if (isset($_POST[input_54_11]) and $_POST[input_54_11] == 9) { $esm_change .= '9,'; } if (isset($_POST[input_54_12]) and $_POST[input_54_12] == 26) { $esm_change .= '26,'; } if (isset($_POST[input_54_13]) and $_POST[input_54_13] == 872) { $esm_change .= '872,'; } if (isset($_POST[input_54_14]) and $_POST[input_54_14] == 3) { $esm_change .= '3,'; } if (isset($_POST[input_54_15]) and $_POST[input_54_15] == 11) { $esm_change .= '11,'; } $esm_change = trim($esm_change, $seperator); $key = '_myesm_esn'; $single = true; update_user_meta($user_id, $key, $esm_change); } else { //mail('*****@*****.**','SF User UPloaded FAILED 2nd try',print_r($sfaccountresponse)); } } if (!empty($entry[48])) { //check if they want the pub, if so upload it, in a custom object so we cannot just add it if it is eSchool News. if ($entry[48] == 'Yes') { // add subscription $upsertResponse2 = $mySforceConnectionu->upsert('WP_ID__c', array($newSubReq), 'Subscription_Request__c'); if ($upsertResponse2->success == 1) { } else { //try again sleep(1); $upsertResponse2 = $mySforceConnectionu->upsert('WP_ID__c', array($newSubReq), 'Subscription_Request__c'); } } } $user_login = $entry[30]; //use the input if of the username $user_pass = $entry[47]; //use the input if of the password //pass the above to the wp_signon function $user = wp_signon(array('user_login' => $user_login, 'user_password' => $user_pass, 'remember' => true)); //check if we need to give a message. if (!empty($entry[48]) and $entry[48] == 'No') { if ($upsertResponse->success == 1) { if ($_GET['redirect_to']) { $redirectto = $_GET['redirect_to']; $reditchk = strpos($redirectto, "eschoolnews"); if ($reditchk > 1) { //we are ok no need to do anything... } else { $redirectto = 'http://www.eschoolnews.com/'; } wp_safe_redirect($redirectto); sleep(2); exit; break; } } } else { if (!empty($entry[48])) { if ($upsertResponse2->success == 1) { if ($_GET['redirect_to']) { $redirectto = $_GET['redirect_to']; $reditchk = strpos($redirectto, "eschoolnews"); if ($reditchk > 1) { //we are ok no need to do anything... } else { $redirectto = 'http://www.eschoolnews.com/'; } wp_safe_redirect($redirectto); sleep(2); exit; break; } } } } $formsuccess = validateint($_GET['success']); }
function SF_Account_Upsert($entry, $form) { global $wpdb; $user_email = $entry[4]; ini_set("soap.wsdl_cache_enabled", "0"); $USERNAME = "******"; //- variable that contains your Salesforce.com username (must be in the form of an email) $PASSWORD = "******"; //- variable that contains your Salesforce.com password $TOKEN = "qhO7UhNTUrYp8XU5eF1SRomDp"; //- variable that contains your Salesforce.com password require_once ABSPATH . '/soapclient/SforceEnterpriseClient.php'; require_once ABSPATH . '/soapclient/SforceHeaderOptions.php'; // Salesforce Login information $wsdl = ABSPATH . '/soapclient/eSNenterprise.wsdl.xml'; $mySforceConnectionu = new SforceEnterpriseClient(); $mySoapClient = $mySforceConnectionu->createConnection($wsdl); $mylogin = $mySforceConnectionu->login($USERNAME, $PASSWORD . $TOKEN); //determine site we are on - ecampus, eclassroom, or enews $sitesource = $entry[26]; $entrysubtype = $entry[21]; if ($entrysubtype == 'Print') { $pubsubtype = "Print"; $pubforid = 1; } else { $pubsubtype = "Digital"; $pubforid = 2; } if ($sitesource !== "") { $school = strpos($sitesource, "eschoolnews"); $campus = strpos($sitesource, "ecampusnews"); $classroom = strpos($sitesource, "eclassroomnews"); } else { $school = strpos($_SERVER["SERVER_NAME"], "eschoolnews"); $campus = strpos($_SERVER["SERVER_NAME"], "ecampusnews"); $classroom = strpos($_SERVER["SERVER_NAME"], "eclassroomnews"); } if ($school !== false) { $name = 'eSchoolNews ' . $pubsubtype . ' Subscription'; $linksource = "eschoolnews"; $pubforid = $pubforid . '1'; } elseif ($campus !== false) { $name = 'eCampusNews ' . $pubsubtype . ' Subscription'; $linksource = "ecampusnews"; $pubforid = $pubforid . '2'; } elseif ($classroom !== false) { $newSubReq["Name"] = 'eClassroomNews ' . $pubsubtype . ' Subscription'; $linksource = "eclassroomnews"; $pubforid = $pubforid . '3'; } else { $name = 'Unknown'; $linksource = "Unk"; $pubforid = $pubforid . '4'; } //query sfdc to see if user exists based on email address $sfaccountdataquery = "Select Id, WP_Unique_ID__c from Account where Email_as_ExternalID__c ='" . $user_email . "' and IsPersonAccount=true"; $sfaccountresponse = $mySforceConnectionu->query($sfaccountdataquery); $wp_id = ""; //create array for account to get upserted $newperson = array(); if (count($sfaccountresponse->records) > 0) { $wp_id = $sfaccountresponse->records[0]->WP_Unique_ID__c; } else { //see if user is in WP and get id $wp_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$WPDB->USERS} WHERE USER_EMAIL='" . $user_email . "'")); $newperson['Source__c'] = $_SERVER["SERVER_NAME"]; //only want to populate source when first creating person account } if (is_null($wp_id)) { $wp_id = $user_email; } $newperson['WP_Unique_ID__c'] = $wp_id; //query sfdc subscription request object to see if there is an existing pending subscription request $sfsubreqdataquery = "Select Id, wp_id__c, sub_status__c, Title__c, name from Subscription_Request__c where Email__c = '" . $user_email . "' and Sub_Status__c = 'Pending' and name = '" . $name . "'"; $sfsubreqresponse = $mySforceConnectionu->query($sfsubreqdataquery); if (count($sfsubreqresponse->records) > 0) { $wp_subreq_id = $pubforid . $sfsubreqresponse->records[0]->WP_ID__c; } else { //there is no sub request record, need to create an external id //echo 'No Pending'.PHP_EOL; $sfcountquery = "Select id from Subscription_Request__c where Email__c = '" . $user_email . "'"; $sfcountresponse = $mySforceConnectionu->query($sfcountquery); //echo 'count '.$sfcountresponse->size; $reccount = $sfcountresponse->size + 1; $wp_subreq_id = $pubforid . $user_email; //$wp_subreq_id = $pubforid . $reccount.$user_email; } //create new array for subscription request to be upserted $newSubReq = array(); $newSubReq['Source__c'] = "Web"; $newSubReq['WP_ID__c'] = substr($wp_subreq_id, 0, 20); //need to limit length to 20 characters //echo $newSubReq['WP_ID__c'].PHP_EOL.PHP_EOL; $newSubReq["Sub_Status__c"] = 'Pending'; $newSubReq['Personal_Question__c'] = "What was your high school mascot?"; $newSubReq['Request_URL__c'] = $_SERVER["SERVER_NAME"]; $newSubReq["Name"] = $name; $newSubReq['Request_Date__c'] = date("Y-m-d"); $sfFEIDquery = "Select feid__c, wp_id__c from Subscription_Request__c where Email__c = '" . $user_email . "' and Sub_Status__c = 'Processed' and name = '" . $name . "'"; $sfFEIDresponse = $mySforceConnectionu->query($sfFEIDquery); if (count($sfFEIDresponse->records) > 0) { //echo 'Processed Found'.PHP_EOL; //echo 'wp id = '.$sfFEIDresponse->records[0]->WP_ID__C.PHP_EOL; $newSubReq['FEID__c'] = $sfFEIDresponse->records[0]->FEID__c; } if (!empty($entry[4])) { //if (strpos($entry[4], 'esmnoemailsupplied') !== false) { $newperson['PersonEmail'] = $entry[4]; $newSubReq['Email__c'] = $entry[4]; $newperson['Email_as_ExternalID__c'] = $entry[4]; //12-20-2011 //} } if (!empty($entry[1])) { $newperson['FirstName'] = $entry[1]; $newSubReq['First_Name__c'] = $entry[1]; } if (!empty($entry[2])) { $newperson['LastName'] = $entry[2]; $newSubReq['Last_Name__c'] = $entry[2]; } if (!empty($entry[3])) { $newperson['Organization__c'] = $entry[3]; $newSubReq['Organization__c'] = $entry[3]; } if (!empty($entry[5])) { $newperson['PersonTitle'] = $entry[5]; $newSubReq['Title__c'] = $entry[5]; } if (!empty($entry[6])) { $newperson['Company_Type__c'] = $entry[6]; $newSubReq['Organization_Type__c'] = $entry[6]; } if (!empty($entry[7])) { $newperson['PersonMailingStreet'] = $entry[7]; $newSubReq['Address1__c'] = $entry[7]; } if (!empty($entry[8])) { $newperson['Mailing_Address_2__c'] = $entry[8]; $newSubReq['Address2__c'] = $entry[8]; } if (!empty($entry[9])) { $newperson['PersonMailingCity'] = $entry[9]; $newSubReq['city__c'] = $entry[9]; } if (!empty($entry[10])) { $newperson['PersonMailingState'] = $entry[10]; $newSubReq['State__c'] = $entry[10]; } if (!empty($entry[12])) { $newperson['PersonMailingPostalCode'] = $entry[12]; $newSubReq['Zip__c'] = $entry[12]; } if (!empty($entry[13])) { $newperson['PersonMailingCountry'] = $entry[13]; $newSubReq['Country__c'] = $entry[13]; } if (!empty($entry[22])) { $newperson['Phone'] = $entry[22]; $newSubReq['Phone__c'] = $entry[22]; } if (!empty($entry[23])) { $newperson['Grade_Level__c'] = $entry[23]; } if (!empty($entry[24])) { $newperson['Subject_Taught__c'] = $entry[24]; } if (!empty($entry[25])) { $newperson['Industry__c'] = $entry[25]; } if (!empty($entry[14])) { $newSubReq['Personal_Answer__c'] = $entry[14]; } if (!empty($entry[29])) { $newSubReq['Promo_Code__c'] = $entry[29]; } $upsertResponse = $mySforceConnectionu->upsert('Email_as_ExternalID__c', array($newperson), 'Account'); //echo '<pre> 189<br>'; //echo print_r($upsertResponse); //echo '</pre>'; if ($upsertResponse->success == 1) { update_user_meta($user_id, "sfid", $upsertResponse->id); $sfaccountdataquery = "Select Id, PersonContactId from Account where PersonEmail ='" . $entry[4] . "'"; $sfaccountresponse = $mySforceConnectionu->query($sfaccountdataquery); $sfAccountid = $sfaccountresponse->records[0]->Id; // echo '<pre> 195<br>'; //echo print_r($sfaccountresponse); //mail('*****@*****.**','SF Subscription upserted account', print_r($sfaccountresponse).print_r($sfAccountid)); //echo '</pre>'; //since upserted account successfully, now upsert sub request //get the person account id just created to use in the subscription request record $newSubReq['Person_Account__c'] = $sfAccountid; //need to set renewal link $isrenewal = strpos($entry[source_url], 'sfid'); if ($isrenewal !== false) { $renewalurl = substr($entry[source_url], 0, $isrenewal) . 'sfid=' . $sfAccountid . '&source=' . $linksource; } else { if (strpos($entry[source_url], '?' !== false)) { $renewalurl = $entry[source_url] . '&sfid=' . $sfAccountid . '&source=' . $linksource; } else { $renewalurl = $entry[source_url] . '?sfid=' . $sfAccountid . '&source=' . $linksource; } } $newSubReq['Renewal_Link__c'] = substr($renewalurl, 0, 254); $upsertResponse2 = $mySforceConnectionu->upsert('WP_ID__c', array($newSubReq), 'Subscription_Request__c'); //echo '<pre> 220<br>' . $Subscription_Request__c; //print_r($newSubReq); //print_r($sfaccountresponse); //echo '</pre>'; if ($upsertResponse2->success == 1) { print_r($sfaccountresponse); //mail('*****@*****.**','SF Subscription request upload success','we are ok'); } else { //mail('*****@*****.**','SF Subscription Request UPload FAILED', print_r($newSubReq).print_r($upsertResponse2)); } } else { //mail('*****@*****.**','SF Subscription form UPload FAILED',print_r($sfaccountresponse)); //mail('*****@*****.**','an SF Subscription account upload FAILED ','Email address that failed is '.$user_email); //echo '<pre> 236<br>'; //print_r($newSubReq); //print_r($sfaccountresponse); //echo '</pre>'; } }
} } ini_set("soap.wsdl_cache_enabled", "0"); $USERNAME = "******"; //- variable that contains your Salesforce.com username (must be in the form of an email) $PASSWORD = "******"; //- variable that contains your Salesforce.com password $TOKEN = "qhO7UhNTUrYp8XU5eF1SRomDp"; //- variable that contains your Salesforce.com password define("SOAP_CLIENT_BASEDIR", "./soapclient"); require_once SOAP_CLIENT_BASEDIR . '/SforceEnterpriseClient.php'; require_once SOAP_CLIENT_BASEDIR . '/SforceHeaderOptions.php'; $mySforceConnectionu = new SforceEnterpriseClient(); $mySoapClient = $mySforceConnectionu->createConnection(SOAP_CLIENT_BASEDIR . '/eSNenterprise.wsdl.xml'); $mylogin = $mySforceConnectionu->login($USERNAME, $PASSWORD . $TOKEN); $upsertResponse = $mySforceConnectionu->upsert('Email_as_ExternalID__c', array($changeemailsubs), 'Account'); if ($upsertResponse->success == 1) { // echo print_r($upsertResponse); } else { if (isset($_POST['all_newsletters'])) { $wpdb->query($wpdb->prepare("INSERT INTO emailsuppression (txtemail, dtdateadd, txtipaddress) VALUES (%s, %s, %s )", $unsubemailb, $dtDate, $txtIP)); } else { mail('*****@*****.**', 'FAILED UNSUBSCRIBE REQUEST USER NOT FOUND IN SF', $message); $wpdb->query($wpdb->prepare("INSERT INTO emailsuppression (txtemail, dtdateadd, txtipaddress) VALUES (%s, %s, %s )", $unsubemailb, $dtDate, $message)); } } } else { if (isset($_POST['all_newsletters'])) { $wpdb->query($wpdb->prepare("INSERT INTO emailsuppression (txtemail, dtdateadd, txtipaddress) VALUES (%s, %s, %s )", $unsubemailb, $dtDate, $txtIP)); } else { if (isset($_POST['eschool_news_this_week'])) {
function SF_Account_Upsert226($entry, $form) { global $wpdb; ini_set("soap.wsdl_cache_enabled", "0"); $USERNAME = "******"; //- variable that contains your Salesforce.com username (must be in the form of an email) $PASSWORD = "******"; //- variable that contains your Salesforce.com password $TOKEN = "qhO7UhNTUrYp8XU5eF1SRomDp"; //- variable that contains your Salesforce.com password require_once ABSPATH . '/soapclient/SforceEnterpriseClient.php'; require_once ABSPATH . '/soapclient/SforceHeaderOptions.php'; // Salesforce Login information $wsdl = ABSPATH . '/soapclient/eSNenterprise.wsdl.xml'; $mySforceConnectionu = new SforceEnterpriseClient(); $mySoapClient = $mySforceConnectionu->createConnection($wsdl); $mylogin = $mySforceConnectionu->login($USERNAME, $PASSWORD . $TOKEN); $loginname = $entry[30]; $thenewuser = get_user_by('login', $loginname); if ($thenewuser) { $user_id = $thenewuser->ID; } else { sleep(1); $thenewuser = get_user_by('login', $loginname); $user_id = $thenewuser->ID; } $newperson = array(); $newperson['WP_Unique_ID__c'] = $user_id; $newperson['WP_ID__c'] = $user_id; $newperson['Source__c'] = $_SERVER["SERVER_NAME"]; $newperson['Site_Registered_On__c'] = $_SERVER["SERVER_NAME"]; $wp_subreq_id = '21' . $entry[4]; //21 = digital ecn [4] is email if (!empty($entry[4])) { $newperson['PersonEmail'] = $entry[4]; $newSubReq['Email__c'] = $entry[4]; $newperson['Email_as_ExternalID__c'] = $entry[4]; } if (!empty($entry[1])) { $newperson['FirstName'] = $entry[1]; $newSubReq['First_Name__c'] = $entry[1]; } if (!empty($entry[2])) { $newperson['LastName'] = $entry[2]; $newSubReq['Last_Name__c'] = $entry[2]; } if (!empty($entry[61])) { $newperson['Unique_Title__c'] = $entry[61]; $newSubReq['Unique_Title__c'] = $entry[61]; } if (!empty($entry[5])) { $newperson['PersonTitle'] = $entry[5]; $newSubReq['Title__c'] = $entry[5]; } $OptedOutflag = 0; if (!empty($entry['57.1'])) { $newperson['eSN_This_Week__c'] = $entry['57.1']; if ($entry['57.1'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eSN_This_Week__c'] = "Not Subscribed"; } if (!empty($entry['57.2'])) { $newperson['eSN_Today__c'] = $entry['57.2']; if ($entry['57.2'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eSN_Today__c'] = "Not Subscribed"; } if (!empty($entry['57.3'])) { $newperson['eSN_IT_School_Leadership__c'] = $entry['57.3']; if ($entry['57.3'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eSN_IT_School_Leadership__c'] = "Not Subscribed"; } if (!empty($entry['57.4'])) { /* Check on this field */ $newperson['MyeCN_EdTech_Leadership__c'] = $entry['57.4']; if ($entry['57.4'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['MyeCN_EdTech_Leadership__c'] = "Not Subscribed"; } if (!empty($entry['57.5'])) { $newperson['eCN_Today__c'] = $entry['57.5']; if ($entry['57.5'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eCN_Today__c'] = "Not Subscribed"; } if (!empty($entry['57.6'])) { $newperson['eCN_This_Week__c'] = $entry['57.6']; if ($entry['57.6'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eCN_This_Week__c'] = "Not Subscribed"; } if (!empty($entry['57.7'])) { $newperson['eCN_IT_School_Leadership__c'] = $entry['57.7']; if ($entry['57.7'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eCN_IT_School_Leadership__c'] = "Not Subscribed"; } if (!empty($entry['57.8'])) { $newperson['eClassroom_News__c'] = $entry['57.8']; if ($entry['57.8'] == 'Subscribed') { $OptedOutflag = 1; } } else { $newperson['eClassroom_News__c'] = "Not Subscribed"; } $newperson['eSN_Offers__c'] = "Not Subscribed"; $newperson['Partner_Offers__c'] = "Not Subscribed"; $newperson['eCN_Offers__c'] = "Not Subscribed"; $newperson['eCN_Partners__c'] = "Not Subscribed"; //special update unsub flag if they subscribe to anything... else do not change it. if ($OptedOutflag == 1) { $newperson['PersonHasOptedOutOfEmail'] = false; } $upsertResponse = $mySforceConnectionu->upsert('Email_as_ExternalID__c', array($newperson), 'Account'); if ($upsertResponse->success == 1) { //Saved for later use mail('*****@*****.**', '226 SF Subscription request success', 'line 138'); } else { $upsertResponse = $mySforceConnectionu->upsert('Email_as_ExternalID__c', array($newperson), 'Account'); mail('*****@*****.**', '226 SF Subscription request failed', 'line 142'); } $formsuccess = validateint($_GET['success']); }