简体   繁体   English

需要帮助将 wordpress 注册表连接到 infusionsoft

[英]need some help connecting wordpress registration form to infusionsoft

I'm new to all of this and I've tried searching myself but didn't find what I needed.我对这一切都很陌生,我尝试过搜索自己,但没有找到我需要的东西。 I need to connect the default WordPress registration form to infusionsoft.我需要将默认的 WordPress 注册表连接到 infusionsoft。 So every time a new member registers, I get their email address in my contact list at infusionsoft.因此,每次有新成员注册时,我都会在 infusionsoft 的联系人列表中获得他们的 email 地址。 Hope I explained it correctly.希望我解释正确。 Feel free to edit my question.随意编辑我的问题。

There's a lot you have to set up, so I'll just skim over the things you need to do before the solution.您需要设置很多东西,所以我将略读在解决方案之前您需要做的事情。 I've added some links that you can refer to as you go.我添加了一些链接,您可以参考 go。

What you'll first need is Infusionsoft's PHP SDK.您首先需要的是 Infusionsoft 的 PHP SDK。 If you're unsure of how to set it up, refer to this: https://blog.terresquall.com/2021/03/using-keaps-aka-infusionsoft-php-sdk-2021/如果您不确定如何设置,请参考: https://blog.terresquall.com/2021/03/using-keaps-aka-infusionsoft-php-sdk-2021/

Create the Authentication bit as a menu page in your Wordpress Admin dashboard.在 Wordpress 管理仪表板中将身份验证位创建为菜单页面。

After you've figured out the authentication, you can save the generated access token to your Infusionsoft API as an option within WordPress.确定身份验证后,您可以将生成的访问令牌保存到您的 Infusionsoft API 作为 WordPress 中的选项。 Use register_setting() andget_option() to save your Access Token for the API calls in your plugin/theme.使用register_setting()get_option()为插件/主题中的 API 调用保存访问令牌。

After that, you need to use the user_register hook, which will be called after the user registers, to make the API call that will ultimately send over the registration details to infusionsoft:之后,您需要使用将在用户注册后调用的 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);

    

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM