Please help! The only documented way to add a new registered user on a WordPress site as a Contact in ActiveCampaign is via Zapier. That’s not working for me, and research indicates I’m not alone.
So, I’ve written a plugin based on the code provided here:
https://erickar.be/blog/adding-a-user-to-active-campaign-on-wordpress-new-user-signup
I’ve got this working to add the contact to the desired list. The email address gets added, but the First Name does not. I’ve tested various options for the field ID (e.g.; first_name, firstname, firstName) for the First Name but it never gets added to the Contact Profile in Active Campaign. I’ve confirmed the first_name is getting captured on the reg form, and it is getting added to the WordPress user profile. But it never gets shows up in the Contact record.
This is a major roadblock to launching our onboarding automations. Any guidance is greatly appreciated. Extra Credit: The autoresponder is not getting sent either…?
Below is the relative code from the plugin that I think matters for this discussion.
// If this is a subscriber, then let's do this!
if ( in_array( 'subscriber', $user_roles, true ) ) {
$first_name = $user_info->first_name;
$last_name = $user_info->last_name;
$user_email = $user_info->user_email;
$url = 'https://myaccount.api-us1.com';
$params = array(
'api_key' => 'MYAPIKEYMYAPIKEYMYAPIKEYMYAPIKEY',
'api_action' => 'contact_add',
'api_output' => 'serialize',
);
// here we define the data we are posting in order to perform an update
$post = array(
'email' => $user_email,
'firstName' => $first_name, // Optional if you don't collect this in your signup form
'lastName' => $last_name, // Optional if you don't collect this in your signup form
'p[2]' => 2, // example list ID (REPLACE '3' WITH ACTUAL LIST ID, IE: p[5] = 5)
'status[2]' => 1, // 1: active, 2: unsubscribed (REPLACE '3' WITH ACTUAL LIST ID, IE: status[5] = 1)
'instantresponders[2]' => 1, // set to 0 to if you don't want to send instant autoresponders
);
Screenshots for reference:
Thank You!