Adding New WordPress User as Contact via API

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!

1 Like

Hey there! Sorry we missed this when it was originally published, but in the spirit of providing insight on this question, I’ll be happy to take a look!

When it comes to our Wordpress plugin, our native integration is a great way to get this done. You can check our Video Tutorial to learn how this process works.

That said, it is also very important to highlight that, since our team doesn’t provide coding support, in case you are looking for technical assistance, it might be best to double-check directly with your developer, or you can also check our Certified Consultants directory in case you are interested in hiring an expert!

Please consider this topic closed. I fixed the issue long ago…