Skip to content

Instantly share code, notes, and snippets.

@timothyjensen
Last active May 5, 2017 13:02
Show Gist options
  • Save timothyjensen/0efadea1e7bd1e442c9c4035c5078d5a to your computer and use it in GitHub Desktop.
Save timothyjensen/0efadea1e7bd1e442c9c4035c5078d5a to your computer and use it in GitHub Desktop.
Example usage for ForwardJump Infusionsoft SDK
<?php
add_action( 'wp_login', 'fj_infusionsoft_api_sample_usage', 10, 2 );
/**
* Adds a user as an Infusionsoft contact after they log in to WordPress.
*
* @param string $user_login WP user login
* @param object $user WP user object
*/
function fj_infusionsoft_api_sample_usage( $user_login, $user ) {
// Instantiates the Infusionsoft object and ensures that we have a valid access token.
$infusionsoft = fj_infusionsoft_init();
// Gather relevant user data
$user_email = $user->data->user_email;
$user_first_name = get_userdata( $user->ID )->first_name;
$user_last_name = get_userdata( $user->ID )->last_name;
$contact = array(
'Email' => $user_email,
'FirstName' => $user_first_name,
'LastName' => $user_last_name
);
// Adds the WP user as an Infusionsoft contact if they are not already in Infusionsoft
$contact_id = $infusionsoft->contacts('xml')->addWithDupCheck( $contact, 'Email' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment