Support has been upgraded!
The Support Forum is closed. Not to worry! Providing the top quality support you expect and we're known for will continue! We're not ending support, just changing where you submit requests. This will provide you with the best experience possible.
Premium Support
Have you purchased an addon for Connections such as one of our premium templates or extensions with a valid license and you need help?
Please open a Support Ticket in your user account.
Free Support
Are you using the free Connections plugin? Don't worry, you are still very important to us! We are still providing you with the same high quality support that we're known for.
Please open a new support topic in the WordPress support forums for Connections.
- This topic has 18 replies, 3 voices, and was last updated 9 years ago by
Steven Zahm.
-
AuthorPosts
-
05/23/2014 at 7:51 pm #291982
Eric Bobrow
ParticipantOne other tiny thing – I’m wondering if there is a typo in the second line of your snippet – it refers to:
add_filter( 'cnf_add_entry_object'...
while all the other references use “cnl_” rather than “cnf_”.
Should this be “cnf_” as you wrote, or should it be instead “cnl_”?
05/24/2014 at 9:29 am #291990Steven Zahm
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; }
05/24/2014 at 2:13 pm #291991Steven Zahm
Keymaster@ Eric
I add two new action which you can hook into to output the instructions. Here’s snippet that will work with the beta of Link:
add_action( 'cnl_admin_before_metaboxes', 'cnl_custom_content_before' ); function cnl_custom_content_before( $action ) { switch ( $action ) { case 'add': echo '<div><p>Special Instructions when adding an entry</p></div>'; break; case 'edit': echo '<div><p>Special Instructions when editing an entry</p></div>'; break; } }
05/24/2014 at 4:05 pm #291995Eric Bobrow
ParticipantHi Steven –
Thank you so much for writing up all the code snippets. I am sure we are pretty close now.
As you instructed, I replaced line 37 and removed the rest of my test code from manage.php. I activated the two code snippets based on the most recent versions you posted.
There appears to be a problem in loading the Infusionsoft code, which was working OK when called from inside the manage.php file.
When I use the code snippet as you wrote earlier, the page breaks – it only shows the admin sidebar plus the header “Connections: Add My Directory Entry”, with the form missing and the rest of the browser window blank.
When I leave out the Infusionsoft code, I can prepopulate the data using the info that comes from DAP for the logged in user. Hooray!
Here is the code that works well – it only relies on DAP info:
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(); $emailAddress = $user->getEmail(); $firstName = $user->getFirst_name(); $lastName = $user->getLast_name(); // Setup the name data to prepopulate. $entry->setFirstName( $firstName ); $entry->setLastName( $lastName ); // Setup the email data to prepopulate. $email = array(); $email[1] = array(); $email[1]['type'] = 'personal'; $email[1]['address'] = $emailAddress; // Store the email address in the cache. $entry->setEmailAddresses( $email ); // ACCESS USER INFO FROM INFUSIONSOFT API include_once '/wp-content/plugins/connections-link/submenus/isdk.php'; // The following line causes an error, so it is commented out: // $myApp = new iSDK; // Remaining Infusionsoft code temporarily removed } return $entry; }
In my earlier testing, I successfully placed and referenced the Infusionsoft API files (a few individual files plus an xmlrpc.3.0 directory) in the same submenus directory as the manage.php file. This is why the original include_once statement refers to the file locally:
include_once 'isdk.php';
The snippet breaks when the following line is called:
$myApp = new iSDK;
I tried modifying the line to:
include_once '/wp-content/plugins/connections-link/submenus/isdk.php';
but the snippet still breaks when the following line [$myApp = new iSDK;] is called.
Do you have any suggestions for where to place and how to reference the Infusionsoft API files successfully? Is there another directory that they should be placed into so that they function properly?
By the way, the snippet for outputting instructions does not appear to do anything. Is that because it isn’t called in Link 1.0.5 and will only be activated when I’ve got the beta set up?
Eric
-
This reply was modified 9 years ago by
Eric Bobrow.
05/24/2014 at 4:22 pm #291998Eric Bobrow
ParticipantOne other thing that I realized is important – I only want the data to prepopulate when a new directory entry is being added.
If a user comes back to the form to edit their entry, it should leave everything alone, and let them edit whatever they want. It should not pull info from DAP or Infusionsoft in this case.
By the way, in my earlier testing, I noticed that the default for new entries was to make them either Private or Unlisted. I’d like to set the default to be Public, so they only become Private or Unlisted if explicitly chosen. Can you provide a code snippet for setting the value of radio buttons to my preferred choice?
Also, I’d like to set this up for Individuals only, rather than providing the choice of Organization too. This will make it easier to have a consistent format in the Directory. I found that a couple of the users had chosen “Organization” and their directory entry formatted differently than the others.
Thanks again for all your help!
Eric05/24/2014 at 5:56 pm #291999Steven Zahm
Keymaster@ Eric
re: paths
The paths would be relative to Code Snippets, not Link. I suggest not putting the API files within a plugin folder. Any update will delete the files. Your best course of action is to write your own plugin rather than using Code Snippets that way the API files can reside in your custom plugin. Code Snippets is fantastic for prototyping, testing actions/filters and adding one-off actions/filters but there are limits.Creating a plugin is easy. Just add the plugin header text to the top of a php file, paste in the snippets I gave you after the plugin header text, deactivate the snippets you added, create a new folder in the plugins folder, copy your php file to that new folder and activate your new plugin.
re: instruction action
The action will only work with the betas, not the version you have installed.re: I only want the data to prepopulate when a new directory entry is being added
Right, you’ll have to add conditional code to make sure that happens only when adding a new entry.re: default for new entries was to make them either Private or Unlisted. I’d like to set the default to be Public
As of Connections 0.8.6, the default is to be Public.re: Also, I’d like to set this up for Individuals only, rather than providing the choice of Organization too
function cn_limit_entry_type_to_individual( $atts ){ $atts['entry_type'] = array( __( 'Individual', 'connections' ) => 'individual' ); $atts['default'] = array( 'type' => 'individual', 'visibility' => 'public' ); return $atts; } // Filter to limit to the organization entry type. add_filter( 'cn_metabox_publish_atts', 'cn_limit_entry_type_to_individual' );
05/25/2014 at 8:31 pm #292074Eric Bobrow
ParticipantSteven –
I successfully created a new plugin and have the basic process working. The Infusionsoft API code works nicely when placed directly into the plugin folder. Thank you SO MUCH for your help!
In addition to getting this particular site working the way I need, you have opened my eyes to the world of WP plugin creation and the basics of filters, actions and hooks.
A few quick remaining questions:
1) The code you created for limiting entry types to individuals (above) – should that go into my plugin PHP file?
2) To limit the prepopulation to new records, should I use some variation of the Switch/Case code that I see in manage.php? Will this “case ‘add'” test work in my plugin, or will it only work from within manage.php? It looks like you’re setting the $action variable based on whether the $id is empty or not. I’m not sure what sort of test I can use from within the plugin.
3) Shall I go ahead and create my instructions for form entry and place them as an echo statement within manage.php for now, then transfer them once you send me the beta for Link?
Eric
05/26/2014 at 8:15 am #292096Steven Zahm
Keymaster@ Eric
re: The code you created for limiting entry types to individuals (above) – should that go into my plugin PHP file?
I’d probably would add the code to the plugin.re: Will this “case ‘add’” test work in my plugin, or will it only work from within manage.php?
I’m thing that just wrapping you pre-population code within anif
clause would work fine:if ( $action == 'add' ) { // Your code here. }
re: Shall I go ahead and create my instructions for form entry
I would add them to your plugin right and not add them to the manage.php file at all. The betas are on they way very shortly. I’m pushing out version 0.8.8 of Connections, you’ll need to update to that version prior to running installing the betas … one of the reason I haven’t sent them yet.05/26/2014 at 9:22 am #292103Steven Zahm
Keymaster@ Eric
I just emailed the betas, let me know if you did not receive them.
-
This reply was modified 9 years ago by
-
AuthorPosts
You cannot reply to this support topic. Please open your own support topic.