Last active
May 5, 2017 13:02
-
-
Save timothyjensen/0efadea1e7bd1e442c9c4035c5078d5a to your computer and use it in GitHub Desktop.
Example usage for ForwardJump Infusionsoft SDK
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 | |
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