05/24/2014 at 9:29 am
#291990
Keymaster
@ Eric
The second line is correct. That filter is the equivalent of Form. Two filters need added; one for Form, the other for Link. Both filters call the same function.
For those two filters, you need to make a change to Link, the one I mentioned here on line 37. I’ll try to get both the betas for Form and Link over to you today.
As to how to use the snippet…
A quick look at the code you gave… you should be able to past it after the two cache filter lines. Remove the echos. You can not echo within a filter. Replace my dummy data with the variables from you code. Something like this:
add_filter( 'cnl_admin_add_entry_object', 'cnl_alter_add_entry_object' );
add_filter( 'cnf_add_entry_object', 'cnl_alter_add_entry_object' );
function cnl_alter_add_entry_object( $entry ) {
// Add the filters necessary to save data in the cache.
add_filter( 'cn_email_cached', '__return_true' );
add_filter( 'cn_address_cached', '__return_true' );
include_once '/dap/dap-config.php';
if ( Dap_Session::isLoggedIn() ) {
$session = Dap_Session::getSession();
$user = $session->getUser();
$email = $user->getEmail();
// ACCESS USER INFO FROM INFUSIONSOFT API
include_once 'isdk.php';
$myApp = new iSDK;
if ( $myApp->cfgCon( 'demo' ) ) {
$returnFields = array('Id', 'FirstName', 'LastName', 'City', 'State', 'Country');
$data = $myApp->findByEmail( $email, $returnFields );
$entry->setFirstName( $data['0']['FirstName'] );
$entry->setLastName( $data['0']['LastName'] );
// Setup the email data to prepopulate.
$email = array();
$email[1] = array();
$email[1]['type'] = 'personal';
$email[1]['address'] = $email;
// Store the email address in the cache.
$entry->setEmailAddresses( $email );
// Setup the address data to prepopulate.
$address = array();
$address[1] = array();
$address[1]['type'] = 'home';
$address[1]['city'] = $data['0']['City'];
$address[1]['state'] = $data['0']['State'];
$address[1]['country'] = $data['0']['Country'];
// Store the address data in the cache
$entry->setAddresses( $address );
} else {
echo '<p>Infusionsoft connection error.</p>';
}
}
return $entry;
}
