首页 > 解决方案 > 需要一些帮助将 wordpress 注册表连接到 infusionsoft

问题描述

我对这一切都很陌生,我尝试过搜索自己,但没有找到我需要的东西。我需要将默认的 WordPress 注册表单连接到 infusionsoft。因此,每次有新成员注册时,我都会在 infusionsoft 的联系人列表中找到他们的电子邮件地址。希望我解释正确。随意编辑我的问题。

标签: wordpressformsregistrationinfusionsoft

解决方案


您需要设置很多东西,所以我将略读在解决方案之前您需要做的事情。我添加了一些链接,您可以随时参考。

您首先需要的是 Infusionsoft 的 PHP SDK。如果您不确定如何设置,请参阅: https ://blog.terresquall.com/2021/03/using-keaps-aka-infusionsoft-php-sdk-2021/

在您的 Wordpress 管理仪表板中创建身份验证位作为菜单页面。

确定身份验证后,您可以将生成的访问令牌保存到您的 Infusionsoft API 作为 WordPress 中的一个选项。使用register_setting()get_option()为插件/主题中的 API 调用保存访问令牌。

之后,您需要使用将在用户注册后调用的 user_register 挂钩进行 API 调用,最终将注册详细信息发送到 infusionsoft:

add_action( 'user_register', 'user_to_infusionsoft', 10, 1 );

function user_to_infusionsoft($user_id){
    //Include your infusionsoft PHP SDK path if you haven't already
    
    $infusionsoft = $infusionsoft = new \Infusionsoft\Infusionsoft(array(
    'clientId'     => 'Your API key goes here',
    'clientSecret' => 'Your API secret goes here',
    'redirectUri'  => 'http://yourwebsite.com/authentication.php',
    ));
    
    //Retrieve the access token that you generated and saved from the options
    $token = get_option('infusionsoft_token');
    $infusionsoft->setToken(unserialize($token));
    $user_info = get_userdata($user_id);

//Set up the email in the format to be used by the API
    $user_email =  new \stdClass;
    $user_email->field = 'EMAIL1';
    $user_email->email = $user_info->user_email; 

    $contact = ['given_name' => $user_info->first_name, 'family_name' => $user_info->last_name, 'email_addresses' => [$user_email]];

    $infusionsoft->contacts()->create($contact);

    

}

推荐阅读