Integrate ConvertKit & WPForms: Include custom fields

The plugin Integrate ConvertKit & WPForms lets you add ConvertKit subscribers using a WPForms form on your WordPress site.

The plugin settings let you include the user’s email (a required field) and first name (an optional field).

It also allows you to pass additional fields as custom fields or tags. The built-in functionality should work for most use cases, but you can also use the filter below for more control over the data sent to ConvertKit.

Any additional data you’d like to pass to ConvertKit should be added using the be_convertkit_form_args filter.

The ConvertKit API documentation provides guidance on how you should format your data. Custom fields can be added with a fields parameter, and tags can be added with a tags parameter.

Adding a custom field

Let’s say your form has three fields: First Name, Last Name, and Email. Go to Settings > ConvertKit to configure the first name and email fields.

Place the following code in your theme’s functions.php file or a core functionality plugin. This assumes the Form has an ID of 123 and the Last Name field has a Field ID of 2 (update these to match your specific IDs).

/**
 * Include custom fields in WPForms ConvertKit Form 
 * @link https://www.billerickson.net/code/integrate-convertkit-wpforms-custom-fields/
 *
 * @param array $args, the arguments passed to ConvertKit
 * @param array $fields, the fields in the current form entry 
 * @param array $form_data, data about the current form
 * @return array $args
 */
function be_wpforms_convertkit_custom_fields( $args, $fields, $form_data ) {

	// Only run on Form 123
	if( 123 != $form_data['id'] )
		return $args;

	// last name is in field 2
	if( !empty( $fields[2]['value'] ) )
		$args['fields]['last_name'] = $fields[2]['value'];

	return $args;
}
add_filter( 'be_convertkit_form_args', 'be_wpforms_convertkit_custom_fields', 10, 3 );
Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk